-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing][FrameworkBundle] Allow using env() in route conditions #35747
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
[Routing][FrameworkBundle] Allow using env() in route conditions #35747
Conversation
/cc @nicolas-grekas @HeahDude Here is an experimentation/second implementation of #35727 |
e1f164c
to
84a22c6
Compare
b14fb2e
to
2d30cf3
Compare
src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php
Outdated
Show resolved
Hide resolved
732ef18
to
a40e319
Compare
6177069
to
9431dc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I like it a lot :)
Some minor details and good to go on my side.
src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageTest.php
Outdated
Show resolved
Hide resolved
9431dc6
to
78ad4b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @atailouloute @nicolas-grekas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageTest.php
Outdated
Show resolved
Hide resolved
19682cb
to
5f495d7
Compare
ff17ac7
to
357fc77
Compare
357fc77
to
8259713
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I improved the feature by adding a new routing.expression_language_function
tag to make adding new functions easy. This leverages ServiceProviderInterface
and tagged locators.
8259713
to
1beb7b0
Compare
1beb7b0
to
b574460
Compare
Thank you @atailouloute. |
Thanks for this feature @atailouloute. I used it today to match host using env var; only way to make it dynamic with prebuild Symfony cache. |
…mNaN) This PR was merged into the 5.4 branch. Discussion ---------- [Routing] doc for env() function in route condition Fix #13247 for symfony/symfony#35747 Very useful to match host based on env var. ```yaml blog_list: path: /blog # the controller value has the format 'controller_class::method_name' controller: App\Controller\BlogController::list condition: "context.getHost() == env('APP_MAIN_HOST')" ``` Commits ------- c22dc20 Documentation for env() function in route condition
This is a second implementation of #35727, it overcomes the limitation mentioned by nicolas in (#35727 (comment))
The goal of this feature is to be able to use env variables in Route conditions (it supports also env processors/ loaders)
TODOs: