Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support !php/const in routing yaml #31356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timwsuqld opened this issue May 2, 2019 · 2 comments
Closed

Support !php/const in routing yaml #31356

timwsuqld opened this issue May 2, 2019 · 2 comments

Comments

@timwsuqld
Copy link

Description
Currently we support !php/const for constants in service files. It would be good to be able to use them in routing files as well.

Example
We have some routes that rely on constants, we currently have to put them in to a parameter and then we can use them in our routes

Currently we have:

staff_dashboard:
    host: '%domain_staff%'
    path: /dashboards/default/

Plus a parameter for domain_staff which actually comes from a constant DOMAIN_STAFF.

We could do away with the parameter and just have:

staff_dashboard:
    host: !php/const DOMAIN_STAFF
    path: /dashboards/default/

Fix
In YamlFileLoader.php we change

$parsedConfig = $this->yamlParser->parseFile($path);

to

$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
@xabbuh
Copy link
Member

xabbuh commented May 2, 2019

That's already possible because of the changes made in #25293 which was first released in 4.1.0.

@xabbuh xabbuh closed this as completed May 2, 2019
@timwsuqld
Copy link
Author

@xabbuh Thanks for that. I did search for bugs but didn't find it. I'm in the process of moving to flex in 3.4, so we can upgrade to Symfony 4, so it's good to know once I get there we can make those changes.

Sorry for the noise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants