You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
final class MyMultiListener
{
#[AsEventListener]
public function onCustomEvent(CustomEvent $event): void
There seems to be an implicit assumption here that class CustomEvent has been defined and exists in the same namespace.
If CustomEvent is defined in the App\Event namespace used by other examples in this file then the AsEventListener attribute fails silently and the listener method will never do anything.
Specifically, there is a missing use statement here and it's not easy to debug.
The text was updated successfully, but these errors were encountered:
I found a severe pitfall in this example code:
symfony-docs/event_dispatcher.rst
Lines 198 to 208 in b9f8400
There seems to be an implicit assumption here that class
CustomEvent
has been defined and exists in the same namespace.If
CustomEvent
is defined in theApp\Event
namespace used by other examples in this file then theAsEventListener
attribute fails silently and the listener method will never do anything.Specifically, there is a missing
use
statement here and it's not easy to debug.The text was updated successfully, but these errors were encountered: