Skip to content

Commit

Permalink
Add shared event manager injection to initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Xerkus committed Feb 14, 2013
1 parent 2a51b16 commit b687d32
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions library/Zend/Mvc/Service/ServiceManagerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ public function configureServiceManager(ServiceManager $serviceManager)
}

$serviceManager->addInitializer(function ($instance) use ($serviceManager) {
if ($instance instanceof EventManagerAwareInterface
&& !$instance->getEventManager() instanceof EventManagerInterface
) {
$instance->setEventManager($serviceManager->get('EventManager'));
if ($instance instanceof EventManagerAwareInterface) {
if ($instance->getEventManager() instanceof EventManagerInterface) {
$instance->getEventManager()->setSharedManager(
$serviceManager->get('SharedEventManager')
);
} else {
$instance->setEventManager($serviceManager->get('EventManager'));
}
}
});

Expand Down

0 comments on commit b687d32

Please sign in to comment.