diff --git a/config/module.config.php b/config/module.config.php index ae3f1902..b48cd41a 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -43,6 +43,10 @@ ], ], + 'listeners' => [ + Listener\Mvc::class, + ], + 'view_manager' => [ 'template_map' => [ 'error-hero-module/error-default' => __DIR__.'/../view/error-hero-module/error-default.phtml', diff --git a/spec/ModuleSpec.php b/spec/ModuleSpec.php index 7fd1323d..56474b0c 100644 --- a/spec/ModuleSpec.php +++ b/spec/ModuleSpec.php @@ -5,15 +5,12 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\PDOMySql\Driver; use Doctrine\ORM\EntityManager; -use ErrorHeroModule\Listener\Mvc; use ErrorHeroModule\Module; use Kahlan\Plugin\Double; use Zend\EventManager\EventManagerInterface; use Zend\ModuleManager\Listener\ConfigListener; use Zend\ModuleManager\ModuleEvent; use Zend\ModuleManager\ModuleManager; -use Zend\Mvc\Application; -use Zend\Mvc\MvcEvent; use Zend\ServiceManager\ServiceLocatorInterface; describe('Module', function () { @@ -161,27 +158,4 @@ }); - describe('->onBootstrap()', function () { - - it('pull Mvc Listener and use it to attach with EventManager', function () { - - $application = Double::instance(['extends' => Application::class, 'methods' => '__construct']); - $mvcListener = Double::instance(['extends' => Mvc::class, 'methods' => '__construct']); - $serviceManager = Double::instance(['implements' => ServiceLocatorInterface::class]); - $eventManager = Double::instance(['implements' => EventManagerInterface::class]); - $mvcEvent = Double::instance(['extends' => MvcEvent::class]); - - expect($mvcListener)->toReceive('attach')->with($eventManager); - - allow($application)->toReceive('getServiceManager')->andReturn($serviceManager); - allow($application)->toReceive('getEventManager')->andReturn($eventManager); - allow($serviceManager)->toReceive('get')->with(Mvc::class)->andReturn($mvcListener); - allow($mvcEvent)->toReceive('getApplication')->andReturn($application); - - $this->module->onBootstrap($mvcEvent); - - }); - - }); - }); diff --git a/src/Module.php b/src/Module.php index 05ceaddf..d8b22370 100644 --- a/src/Module.php +++ b/src/Module.php @@ -5,7 +5,6 @@ use Doctrine\ORM\EntityManager; use Zend\ModuleManager\ModuleEvent; use Zend\ModuleManager\ModuleManager; -use Zend\Mvc\MvcEvent; class Module { @@ -64,16 +63,6 @@ public function convertDoctrineToZendDbConfig(ModuleEvent $event) $services->setAllowOverride($allowOverride); } - public function onBootstrap(MvcEvent $e) - { - $app = $e->getApplication(); - $services = $app->getServiceManager(); - $eventManager = $app->getEventManager(); - - $mvcListenerAggregate = $services->get(Listener\Mvc::class); - $mvcListenerAggregate->attach($eventManager); - } - public function getConfig() { return include __DIR__.'/../config/module.config.php';