Add listener config to EventManager#83
Conversation
04322c4 to
bed1895
Compare
bed1895 to
f17cfd9
Compare
|
Thank you for your PR. However, I don't really feel we need this change, to be honest. Those listener objects are a piece of glue code solely meant to be consumed by the |
|
I'm not sure to follow, those listeners can be declared outside. See for instance https://symfony.com/doc/current/doctrine/events.html#doctrine-lifecycle-listeners. And if you want to see the related code: Changing the method name can be useful to convey what the method does. Also it follows what can be done with the entity listeners. |
Sure, then have the handling method with the ugly event name call another method with a name that you can pick. class MyListener
{
public function someEvent($eventArgs)
{
$this->doSomethingVeryUseful($eventArgs);
}
public function doSomethingVeryUseful($eventArgs)
{
// your handling logic goes here.
}
}
Okay, but we apparently did not need to change EventManager to implement that feature. Why is it suddenly necessary for the feature that you have in mind? |
|
Sure it can be done like this but I thought it would be better to have the possibility to explicitly configure it than having a dynamic call by convention.
The entity listeners do not use the EventManager, they use this class: |
This PR adds the possibility to have configuration when adding a listener to the event manager.
For now, it contains only a
method: when a method is defined, it is used instead of the event name to call the listener.It will allow to define a custom method when adding a listener for instance in Symfony: