Adding an experimental PreExecuteListener #344
Conversation
Hi Ryan, Great addition! What about the order of execution? Is the |
Hey Hugo! Right now, the listener that calls Thanks! |
Nice! Can be useful |
👍 |
I don't see the need for an interface here. I like being explicit in controllers, and adding an explicit call to It looks like it does not really solve a problem that can already be solved quite naturally and without any magic. |
} | ||
|
||
$controllerObject = $controller[0]; | ||
if (!$controllerObject instanceof PreExecuteInterface) { |
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.
I think you should do a check first if $controllerObject
really is an object.
I agree with @fabpot. If you really want to execute that same piece of code for every controller there are alternative solutions of which the most logical: Move it to a service. If you would extract the method of the controller, the page behavior will change because the new Controller most likely won't have that filter. |
Closing. My biggest goal was to help making "param converting" easier (for example, the syntax for param converting Doctrine entities is ugly). But I'm going to tackle that in a different way - #321. Thanks! |
Hi guys!
This is an idea that I wanted feedback on. With this, if you controller implements a new interface, then a
preExecute()
method will be called before executing the action.The problems I'm hoping to make smoother:
@Security
can be used more easily, when you're checking against objects:What do you think of this? Would you use it or not? Any ideas/improvements?
Thanks!