-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Expression language extensibility #12006
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
Expression language extensibility #12006
Conversation
I just needed this not later than this afternoon, so a big 👍 |
interface ExpressionFunctionProviderInterface | ||
{ | ||
/** | ||
* @return Function[] An array of Function instances |
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.
ExpressionFunction[]
IMO, it would be worth providing a compiler pass registering the providers (we ned a separate tag for the security and the routing), to avoid each bundle to register a compiler pass for that |
@stof I agree. This PR is in the early stages, but I wanted some feedback about this approach before investing too much time on it. |
@fabpot this looks good to me. Actually, I already wrapped the functions in an object in my project, to allow registering them with a compiler pass (except that I'm doing |
35f8b78
to
66102d9
Compare
PR ready now. I've added some more tests and a compiler pass. |
ping @symfony/deciders |
66102d9
to
7c24188
Compare
Looks good to me 👍 |
This PR was merged into the 2.6-dev branch. Discussion ---------- Expression language extensibility | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10512 | License | MIT | Doc PR | not yet The way we can add functions to an ExpressionLanguage instance is by using inheritance. #10512 tries to make the expression language in the routing flexible but using inheritance won't work when several bundles want to add functions. So, this PR takes another approach to solve the problem globally. Todo: * [x] add some more tests * [ ] add some docs Commits ------- 7c24188 [FrameworkBundle] added a compiler pass for expression language providers 4195a91 [Routing] added support for custom expression language functions 1a39046 [Security] added support for custom expression language functions 79bcd52 [DependencyInjection] added support for custom expression language functions 184742c [ExpressionLanguage] added ExpressionFunction and ExpressionFunctionProviderInterface
Since symfony#12006, the `ContainerBuilder` contains the `addExpressionLanguageProvider()` method which references a class from the ExpressionLanguage component. By default, the PHPUnit mock API tries to mock all methods of the class being doubled. Since the ExpressionLanguage component is not required to run the tests, creating the mock objects fails when the mock API fails to mock the `addExpressionLanguageProvider()` method.
This PR was merged into the 2.3 branch. Discussion ---------- fix components tests | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Since #12006, the `ContainerBuilder` contains the `addExpressionLanguageProvider()` method which references a class from the ExpressionLanguage component. By default, the PHPUnit mock API tries to mock all methods of the class being doubled. Since the ExpressionLanguage component is not required to run the tests, creating the mock objects fails when the mock API fails to mock the `addExpressionLanguageProvider()` method. Commits ------- 2f2a732 fix components tests
This PR was merged into the 2.6 branch. Discussion ---------- Documented ExpressionLanguage extensibility | Q | A | --- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#12006) | Applies to | 2.6+ | Fixed tickets | #4289 Commits ------- 086885b Applied comments ef4ca42 Documented new tags c553193 Documented expressionlanguage extensibility
The way we can add functions to an ExpressionLanguage instance is by using inheritance. #10512 tries to make the expression language in the routing flexible but using inheritance won't work when several bundles want to add functions.
So, this PR takes another approach to solve the problem globally.
Todo: