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

Skip to content

Add the kernel.controller_arguments event #18440

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

Merged
merged 1 commit into from
Apr 7, 2016

Conversation

stof
Copy link
Member

@stof stof commented Apr 5, 2016

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #18362
License MIT
Doc PR symfony/symfony-docs#6434

I'm not sure this can be integrated in 3.1 due to the feature freeze, but it would be great if it is, as it is a must-have to be able to make the @Security annotation compatible with the new argument resolver system (as we need to be able to run the security assertion after the resolving).

I made the arguments mutable here for consistency with kernel.controller (and @fabpot replied LGTM in the RFC when I suggested it).

/**
* Allows filtering of controller arguments.
*
* You can call getController() to retrieve the controller and getArgument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor inconsistency: getArgument -> getArgument()

@stof stof force-pushed the controller_arguments_event branch from dc19f30 to db73ebd Compare April 5, 2016 07:34
@@ -61,7 +61,7 @@ protected function preDispatch($eventName, Event $event)
protected function postDispatch($eventName, Event $event)
{
switch ($eventName) {
case KernelEvents::CONTROLLER:
case KernelEvents::CONTROLLER_ARGUMENTS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're removing the stopwatch start on controller events then, to apply it only on controller_arguments events ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Taluu this is about starting the stopwatch for the controller execution itself. As there is now an event after the resolution of arguments, I starting it there now, as it makes the timing more accurate (in existing versions, the argument resolution is included in the controller time, even though it is also timed on its own)

@stof
Copy link
Member Author

stof commented Apr 6, 2016

@javiereguiluz thanks for writing the doc PR

@stof
Copy link
Member Author

stof commented Apr 6, 2016

@fabpot @nicolas-grekas can you give your mind on whether this PR can still be considered for 3.1 ?

@fabpot
Copy link
Member

fabpot commented Apr 6, 2016

That's going to be for 3.2 as we are in feature freeze now (except for old PRs that are about to be finished).

@stof
Copy link
Member Author

stof commented Apr 7, 2016

@fabpot this means that SensioFrameworkExtraBundle @Security annotation will be incompatible with argument resolvers in 3.1 (as it must be evaluated with converted arguments), and so we cannot replace ParamConverter by argument resolvers in the bundle until 3.2.

@HeahDude
Copy link
Contributor

HeahDude commented Apr 7, 2016

This event was on the table the day before the feature freeze, it's a nice following of #18308, it deserves a nice exception :)

@linaori
Copy link
Contributor

linaori commented Apr 7, 2016

I agree that this might be a nice addition to speed up the development by ~6 months

@stof stof force-pushed the controller_arguments_event branch from db73ebd to af02e2a Compare April 7, 2016 14:51
@stof
Copy link
Member Author

stof commented Apr 7, 2016

As requested by @fabpot in person, I made the controller callable mutable as well during this event, making it possible to replace the controller by a different callable, after arguments of the original controller are resolved. This is great when wanting to wrap the controller into a callable having a different signature than the original one for instance (@fabpot has such a use case for blackfire btw). And there is a test covering this use case.
As the controller is mutable now, the new event class now extends the FilterControllerEvent

@fabpot
Copy link
Member

fabpot commented Apr 7, 2016

Thank you @stof.

@fabpot fabpot merged commit af02e2a into symfony:master Apr 7, 2016
fabpot added a commit that referenced this pull request Apr 7, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

Add the kernel.controller_arguments event

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18362
| License       | MIT
| Doc PR        | symfony/symfony-docs#6434

I'm not sure this can be integrated in 3.1 due to the feature freeze, but it would be great if it is, as it is a must-have to be able to make the ``@Security`` annotation compatible with the new argument resolver system (as we need to be able to run the security assertion after the resolving).

I made the arguments mutable here for consistency with ``kernel.controller`` (and @fabpot replied LGTM in the RFC when I suggested it).

Commits
-------

af02e2a Add the kernel.controller_arguments event
@javiereguiluz
Copy link
Member

@stof now that this is merged, please share your thoughts about its docs here: symfony/symfony-docs#6434 Thanks!

@stof stof deleted the controller_arguments_event branch April 7, 2016 15:42
@HeahDude
Copy link
Contributor

HeahDude commented Apr 7, 2016

🎉

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

Successfully merging this pull request may close these issues.

7 participants