Skip to content

Commit

Permalink
zendframework#6266 - Optimized and named the `ServiceManagerAwareInit…
Browse files Browse the repository at this point in the history
…ializer`
  • Loading branch information
Ocramius committed May 20, 2014
1 parent d9544fb commit 9f701ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/Zend/Mvc/Service/ServiceManagerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9f701ca

Please sign in to comment.