Skip to content

Commit

Permalink
zendframework#6266 - Optimized and named the `ServiceLocatorAwareInit…
Browse files Browse the repository at this point in the history
…ializer`
  • Loading branch information
Ocramius committed May 20, 2014
1 parent 9f701ca commit 843ad2a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions library/Zend/Mvc/Service/ServiceManagerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,25 @@ class ServiceManagerConfig extends Config
public function __construct(array $configuration = array())
{
$this->initializers = array(
'EventManagerAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceManager) {
'EventManagerAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceLocator) {
if ($instance instanceof EventManagerAwareInterface) {
$eventManager = $instance->getEventManager();

if ($eventManager instanceof EventManagerInterface) {
$eventManager->setSharedManager($serviceManager->get('SharedEventManager'));
$eventManager->setSharedManager($serviceLocator->get('SharedEventManager'));
} else {
$instance->setEventManager($serviceManager->get('EventManager'));
$instance->setEventManager($serviceLocator->get('EventManager'));
}
}
},
'ServiceManagerAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceManager) {
if ($serviceManager instanceof ServiceManager && $instance instanceof ServiceManagerAwareInterface) {
$instance->setServiceManager($serviceManager);
'ServiceManagerAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceLocator) {
if ($serviceLocator instanceof ServiceManager && $instance instanceof ServiceManagerAwareInterface) {
$instance->setServiceManager($serviceLocator);
}
},
'ServiceLocatorAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceLocator) {
if ($instance instanceof ServiceLocatorAwareInterface) {
$instance->setServiceLocator($serviceLocator);
}
},
);
Expand Down Expand Up @@ -138,12 +143,6 @@ public function configureServiceManager(ServiceManager $serviceManager)
{
parent::configureServiceManager($serviceManager);

$serviceManager->addInitializer(function ($instance) use ($serviceManager) {
if ($instance instanceof ServiceLocatorAwareInterface) {
$instance->setServiceLocator($serviceManager);
}
});

$serviceManager->setService('ServiceManager', $serviceManager);
}
}

0 comments on commit 843ad2a

Please sign in to comment.