From 6dfdfe016a3414ebc9cb56475444aaa80b3b7676 Mon Sep 17 00:00:00 2001 From: Dragos Badea Date: Fri, 14 Sep 2012 10:29:49 +0300 Subject: [PATCH 1/2] Changed the previous fix as per pull req zendframework/zf2#2350 discussion --- src/Listener/LocatorRegistrationListener.php | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Listener/LocatorRegistrationListener.php b/src/Listener/LocatorRegistrationListener.php index 471cdea..40f8140 100644 --- a/src/Listener/LocatorRegistrationListener.php +++ b/src/Listener/LocatorRegistrationListener.php @@ -67,26 +67,26 @@ public function onLoadModulesPost(Event $e) $moduleManager = $e->getTarget(); $events = $moduleManager->getEventManager()->getSharedManager(); - if(false !== $events){ - // Shared instance for module manager - $events->attach('Zend\Mvc\Application', 'bootstrap', function ($e) use ($moduleManager) { - $moduleClassName = get_class($moduleManager); - $application = $e->getApplication(); - $services = $application->getServiceManager(); - if (!$services->has($moduleClassName)) { - $services->setService($moduleClassName, $moduleManager); - } - }, 1000); + if(!$events){ + return; } + // Shared instance for module manager + $events->attach('Zend\Mvc\Application', 'bootstrap', function ($e) use ($moduleManager) { + $moduleClassName = get_class($moduleManager); + $application = $e->getApplication(); + $services = $application->getServiceManager(); + if (!$services->has($moduleClassName)) { + $services->setService($moduleClassName, $moduleManager); + } + }, 1000); + if (0 === count($this->modules)) { return; } - if(false !== $events){ - // Attach to the bootstrap event if there are modules we need to process - $events->attach('Zend\Mvc\Application', 'bootstrap', array($this, 'onBootstrap'), 1000); - } + // Attach to the bootstrap event if there are modules we need to process + $events->attach('Zend\Mvc\Application', 'bootstrap', array($this, 'onBootstrap'), 1000); } /** From bea18791df293fb51c1d443c93978825e023fbed Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 14 Sep 2012 11:51:32 -0500 Subject: [PATCH 2/2] [zendframework/zf2#2350] CS fixes and reversions - Use MvcEvent::EVENT_BOOTSTRAP instead of 'bootstrap' - Whitespace around conditional statements --- src/Listener/LocatorRegistrationListener.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Listener/LocatorRegistrationListener.php b/src/Listener/LocatorRegistrationListener.php index 40f8140..42e19c2 100644 --- a/src/Listener/LocatorRegistrationListener.php +++ b/src/Listener/LocatorRegistrationListener.php @@ -67,12 +67,12 @@ public function onLoadModulesPost(Event $e) $moduleManager = $e->getTarget(); $events = $moduleManager->getEventManager()->getSharedManager(); - if(!$events){ + if (!$events) { return; } // Shared instance for module manager - $events->attach('Zend\Mvc\Application', 'bootstrap', function ($e) use ($moduleManager) { + $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, function ($e) use ($moduleManager) { $moduleClassName = get_class($moduleManager); $application = $e->getApplication(); $services = $application->getServiceManager(); @@ -86,7 +86,7 @@ public function onLoadModulesPost(Event $e) } // Attach to the bootstrap event if there are modules we need to process - $events->attach('Zend\Mvc\Application', 'bootstrap', array($this, 'onBootstrap'), 1000); + $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, array($this, 'onBootstrap'), 1000); } /**