In my multi-module application I'm trying to use EventsManager over DI container. Attaching 2 listeners (dispatch:beforeDispatch, dispatch:afterInitialize) to the module's dispatcher.
$eventsManager->attach('dispatch:beforeDispatch', function($event, $dispatcher) {
Tracy\Debugger::fireLog('Module - ' . $event->getType());
});
....
$eventsManager->attach('dispatch:afterInitialize', function($event, $dispatcher) {
Tracy\Debugger::fireLog('Module - ' . $event->getType());
});
Application has a class inherited from Component, and this class also used over DI container. The class constructor is attaching listeners to same events.
The problem is in that only module's dispatch:beforeDispatch listeners are executed, the listener that is declared in the class constructor is not executed. With dispatch:afterInitialize all right, both listeners will be executed.