From 843ad2a94db3fe851660a2a6d8d291f11a967752 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 20 May 2014 18:08:05 +0200 Subject: [PATCH] #6266 - Optimized and named the `ServiceLocatorAwareInitializer` --- .../Zend/Mvc/Service/ServiceManagerConfig.php | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/library/Zend/Mvc/Service/ServiceManagerConfig.php b/library/Zend/Mvc/Service/ServiceManagerConfig.php index 58c32077a2b..72f03c175d2 100644 --- a/library/Zend/Mvc/Service/ServiceManagerConfig.php +++ b/library/Zend/Mvc/Service/ServiceManagerConfig.php @@ -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); } }, ); @@ -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); } }