diff --git a/src/Listener/LocatorRegistrationListener.php b/src/Listener/LocatorRegistrationListener.php index 178793c..95e50dd 100644 --- a/src/Listener/LocatorRegistrationListener.php +++ b/src/Listener/LocatorRegistrationListener.php @@ -69,10 +69,12 @@ public function onLoadModules(Event $e) // Shared instance for module manager $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, function ($e) use ($moduleManager) { $moduleClassName = get_class($moduleManager); + $moduleClassNameArray = explode('\\', $moduleClassName); + $moduleClassNameAlias = end($moduleClassNameArray); $application = $e->getApplication(); $services = $application->getServiceManager(); if (!$services->has($moduleClassName)) { - $services->setService($moduleClassName, $moduleManager); + $services->setAlias($moduleClassName, $moduleClassNameAlias); } }, 1000); diff --git a/src/Listener/ServiceListener.php b/src/Listener/ServiceListener.php index 72621e9..6fd3591 100644 --- a/src/Listener/ServiceListener.php +++ b/src/Listener/ServiceListener.php @@ -244,7 +244,7 @@ protected function serviceConfigToArray($config) if (!$config instanceof ServiceConfig) { throw new Exception\RuntimeException(sprintf( 'Invalid service manager configuration class provided; received "%s", expected an instance of Zend\ServiceManager\Config', - $class + (is_object($config) ? get_class($config) : (is_scalar($config) ? $config : gettype($config))) )); } diff --git a/src/ModuleEvent.php b/src/ModuleEvent.php index e29dd8e..c19b997 100644 --- a/src/ModuleEvent.php +++ b/src/ModuleEvent.php @@ -20,11 +20,11 @@ class ModuleEvent extends Event /** * Module events triggered by eventmanager */ - CONST EVENT_MERGE_CONFIG = 'mergeConfig'; - CONST EVENT_LOAD_MODULES = 'loadModules'; - CONST EVENT_LOAD_MODULE_RESOLVE = 'loadModule.resolve'; - CONST EVENT_LOAD_MODULE = 'loadModule'; - CONST EVENT_LOAD_MODULES_POST = 'loadModules.post'; + const EVENT_MERGE_CONFIG = 'mergeConfig'; + const EVENT_LOAD_MODULES = 'loadModules'; + const EVENT_LOAD_MODULE_RESOLVE = 'loadModule.resolve'; + const EVENT_LOAD_MODULE = 'loadModule'; + const EVENT_LOAD_MODULES_POST = 'loadModules.post'; /** * @var mixed diff --git a/test/Listener/AutoloaderListenerTest.php b/test/Listener/AutoloaderListenerTest.php index 638685b..5eadaa8 100644 --- a/test/Listener/AutoloaderListenerTest.php +++ b/test/Listener/AutoloaderListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/ConfigListenerTest.php b/test/Listener/ConfigListenerTest.php index d92a354..280b686 100644 --- a/test/Listener/ConfigListenerTest.php +++ b/test/Listener/ConfigListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/DefaultListenerAggregateTest.php b/test/Listener/DefaultListenerAggregateTest.php index 39f4dcf..67a881f 100644 --- a/test/Listener/DefaultListenerAggregateTest.php +++ b/test/Listener/DefaultListenerAggregateTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/InitTriggerTest.php b/test/Listener/InitTriggerTest.php index b6f2cf9..aa1b63e 100644 --- a/test/Listener/InitTriggerTest.php +++ b/test/Listener/InitTriggerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/ListenerOptionsTest.php b/test/Listener/ListenerOptionsTest.php index dbc6974..cd22c9b 100644 --- a/test/Listener/ListenerOptionsTest.php +++ b/test/Listener/ListenerOptionsTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/LocatorRegistrationListenerTest.php b/test/Listener/LocatorRegistrationListenerTest.php index 2f27410..c1df4f6 100644 --- a/test/Listener/LocatorRegistrationListenerTest.php +++ b/test/Listener/LocatorRegistrationListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; @@ -122,4 +121,23 @@ public function testModuleClassIsRegisteredWithDiAndInjectedWithSharedInstances( $this->assertInstanceOf('Zend\ModuleManager\ModuleManager', $sharedInstance2); $this->assertSame($this->moduleManager, $locator->get('Foo\Bar')->moduleManager); } + + public function testNoDuplicateServicesAreDefinedForModuleManager() + { + $locatorRegistrationListener = new LocatorRegistrationListener; + $this->moduleManager->getEventManager()->attachAggregate($locatorRegistrationListener); + + $this->moduleManager->loadModules(); + $this->application->bootstrap(); + $registeredServices = $this->application->getServiceManager()->getRegisteredServices(); + + $aliases = $registeredServices['aliases']; + $instances = $registeredServices['instances']; + + $this->assertContains('zendmodulemanagermodulemanager', $aliases); + $this->assertFalse(in_array('modulemanager', $aliases)); + + $this->assertContains('modulemanager', $instances); + $this->assertFalse(in_array('zendmodulemanagermodulemanager', $instances)); + } } diff --git a/test/Listener/ModuleDependencyCheckerListenerTest.php b/test/Listener/ModuleDependencyCheckerListenerTest.php index cd931c1..d3264fd 100644 --- a/test/Listener/ModuleDependencyCheckerListenerTest.php +++ b/test/Listener/ModuleDependencyCheckerListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/ModuleLoaderListenerTest.php b/test/Listener/ModuleLoaderListenerTest.php index 2624897..e25d90c 100644 --- a/test/Listener/ModuleLoaderListenerTest.php +++ b/test/Listener/ModuleLoaderListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/ModuleResolverListenerTest.php b/test/Listener/ModuleResolverListenerTest.php index 97c7d4c..4028af7 100644 --- a/test/Listener/ModuleResolverListenerTest.php +++ b/test/Listener/ModuleResolverListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/OnBootstrapListenerTest.php b/test/Listener/OnBootstrapListenerTest.php index 3215b91..aaedd97 100644 --- a/test/Listener/OnBootstrapListenerTest.php +++ b/test/Listener/OnBootstrapListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/ServiceListenerTest.php b/test/Listener/ServiceListenerTest.php index 8e159c7..2b68fc3 100644 --- a/test/Listener/ServiceListenerTest.php +++ b/test/Listener/ServiceListenerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener; diff --git a/test/Listener/TestAsset/ServiceInvalidReturnModule.php b/test/Listener/TestAsset/ServiceInvalidReturnModule.php index d5b9c43..6db8f5b 100644 --- a/test/Listener/TestAsset/ServiceInvalidReturnModule.php +++ b/test/Listener/TestAsset/ServiceInvalidReturnModule.php @@ -5,18 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener\TestAsset; use stdClass; -/** - * @category Zend - * @package Zend_ModuleManager - * @subpackage UnitTest - */ class ServiceInvalidReturnModule { public function getServiceConfiguration() diff --git a/test/Listener/TestAsset/ServiceProviderModule.php b/test/Listener/TestAsset/ServiceProviderModule.php index b8917f7..e94191c 100644 --- a/test/Listener/TestAsset/ServiceProviderModule.php +++ b/test/Listener/TestAsset/ServiceProviderModule.php @@ -5,16 +5,10 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\Listener\TestAsset; -/** - * @category Zend - * @package Zend_ModuleManager - * @subpackage UnitTest - */ class ServiceProviderModule { public $config; diff --git a/test/ModuleEventTest.php b/test/ModuleEventTest.php index c21bfb4..3c1edfc 100644 --- a/test/ModuleEventTest.php +++ b/test/ModuleEventTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager; diff --git a/test/ModuleManagerTest.php b/test/ModuleManagerTest.php index d75a1c1..d8e603f 100644 --- a/test/ModuleManagerTest.php +++ b/test/ModuleManagerTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager; diff --git a/test/TestAsset/BadConfigModule/Module.php b/test/TestAsset/BadConfigModule/Module.php index 388508f..a174079 100644 --- a/test/TestAsset/BadConfigModule/Module.php +++ b/test/TestAsset/BadConfigModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BadConfigModule; diff --git a/test/TestAsset/BafModule/Module.php b/test/TestAsset/BafModule/Module.php index 8777df3..88d25fb 100644 --- a/test/TestAsset/BafModule/Module.php +++ b/test/TestAsset/BafModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BafModule; diff --git a/test/TestAsset/BamModule/Module.php b/test/TestAsset/BamModule/Module.php index 05f18a0..6874518 100644 --- a/test/TestAsset/BamModule/Module.php +++ b/test/TestAsset/BamModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BamModule; diff --git a/test/TestAsset/BarModule/Module.php b/test/TestAsset/BarModule/Module.php index edef287..7a7aaaf 100644 --- a/test/TestAsset/BarModule/Module.php +++ b/test/TestAsset/BarModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BarModule; diff --git a/test/TestAsset/BazModule/Module.php b/test/TestAsset/BazModule/Module.php index 1e7b0f9..61f7540 100644 --- a/test/TestAsset/BazModule/Module.php +++ b/test/TestAsset/BazModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BazModule; diff --git a/test/TestAsset/BooModule/Module.php b/test/TestAsset/BooModule/Module.php index 829ca69..07e9e8a 100644 --- a/test/TestAsset/BooModule/Module.php +++ b/test/TestAsset/BooModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BooModule; diff --git a/test/TestAsset/BorModule/Module.php b/test/TestAsset/BorModule/Module.php index 5383ad7..cf9f049 100644 --- a/test/TestAsset/BorModule/Module.php +++ b/test/TestAsset/BorModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace BorModule; diff --git a/test/TestAsset/ListenerTestModule/Module.php b/test/TestAsset/ListenerTestModule/Module.php index 3c9e4f6..899bbfc 100644 --- a/test/TestAsset/ListenerTestModule/Module.php +++ b/test/TestAsset/ListenerTestModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ListenerTestModule; @@ -15,11 +14,6 @@ use Zend\ModuleManager\Feature\BootstrapListenerInterface; use Zend\EventManager\EventInterface; -/** - * @category Zend - * @package Zend_ModuleManager - * @subpackage UnitTest - */ class Module implements AutoloaderProviderInterface, LocatorRegisteredInterface, diff --git a/test/TestAsset/ListenerTestModule/src/Foo/Bar.php b/test/TestAsset/ListenerTestModule/src/Foo/Bar.php index ec2073c..9cc3634 100644 --- a/test/TestAsset/ListenerTestModule/src/Foo/Bar.php +++ b/test/TestAsset/ListenerTestModule/src/Foo/Bar.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace Foo; diff --git a/test/TestAsset/LoadOtherModule/Module.php b/test/TestAsset/LoadOtherModule/Module.php index cba4809..8045bca 100644 --- a/test/TestAsset/LoadOtherModule/Module.php +++ b/test/TestAsset/LoadOtherModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace LoadOtherModule; diff --git a/test/TestAsset/MockApplication.php b/test/TestAsset/MockApplication.php index 7fc0482..40e3871 100644 --- a/test/TestAsset/MockApplication.php +++ b/test/TestAsset/MockApplication.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace ZendTest\ModuleManager\TestAsset; diff --git a/test/TestAsset/NotAutoloaderModule/Module.php b/test/TestAsset/NotAutoloaderModule/Module.php index 042e98e..3876094 100644 --- a/test/TestAsset/NotAutoloaderModule/Module.php +++ b/test/TestAsset/NotAutoloaderModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace NotAutoloaderModule; diff --git a/test/TestAsset/NotAutoloaderModule/src/Foo/Bar.php b/test/TestAsset/NotAutoloaderModule/src/Foo/Bar.php index f800f20..a2172b7 100644 --- a/test/TestAsset/NotAutoloaderModule/src/Foo/Bar.php +++ b/test/TestAsset/NotAutoloaderModule/src/Foo/Bar.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace Foo; diff --git a/test/TestAsset/SomeModule/Module.php b/test/TestAsset/SomeModule/Module.php index 5d0572c..37525dd 100644 --- a/test/TestAsset/SomeModule/Module.php +++ b/test/TestAsset/SomeModule/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace SomeModule; diff --git a/test/TestAsset/SubModule/Sub/Module.php b/test/TestAsset/SubModule/Sub/Module.php index de441c0..1c48069 100644 --- a/test/TestAsset/SubModule/Sub/Module.php +++ b/test/TestAsset/SubModule/Sub/Module.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_ModuleManager */ namespace SubModule\Sub;