From 9f701ca14f2364af6c0a313a45396c7298931357 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 20 May 2014 18:06:27 +0200 Subject: [PATCH] #6266 - Optimized and named the `ServiceManagerAwareInitializer` --- library/Zend/Mvc/Service/ServiceManagerConfig.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/Zend/Mvc/Service/ServiceManagerConfig.php b/library/Zend/Mvc/Service/ServiceManagerConfig.php index 258f176bd09..58c32077a2b 100644 --- a/library/Zend/Mvc/Service/ServiceManagerConfig.php +++ b/library/Zend/Mvc/Service/ServiceManagerConfig.php @@ -13,6 +13,7 @@ use Zend\EventManager\EventManagerInterface; use Zend\ServiceManager\Config; use Zend\ServiceManager\ServiceLocatorAwareInterface; +use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManagerAwareInterface; @@ -91,7 +92,7 @@ class ServiceManagerConfig extends Config public function __construct(array $configuration = array()) { $this->initializers = array( - 'EventManagerAwareInitializer' => function ($instance, ServiceManager $serviceManager) { + 'EventManagerAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceManager) { if ($instance instanceof EventManagerAwareInterface) { $eventManager = $instance->getEventManager(); @@ -102,6 +103,11 @@ public function __construct(array $configuration = array()) } } }, + 'ServiceManagerAwareInitializer' => function ($instance, ServiceLocatorInterface $serviceManager) { + if ($serviceManager instanceof ServiceManager && $instance instanceof ServiceManagerAwareInterface) { + $instance->setServiceManager($serviceManager); + } + }, ); $configuration = array_replace_recursive(array( @@ -132,12 +138,6 @@ public function configureServiceManager(ServiceManager $serviceManager) { parent::configureServiceManager($serviceManager); - $serviceManager->addInitializer(function ($instance) use ($serviceManager) { - if ($instance instanceof ServiceManagerAwareInterface) { - $instance->setServiceManager($serviceManager); - } - }); - $serviceManager->addInitializer(function ($instance) use ($serviceManager) { if ($instance instanceof ServiceLocatorAwareInterface) { $instance->setServiceLocator($serviceManager);