5 use InvalidArgumentException,
9 Zend\EventManager\EventCollection,
10 Zend\EventManager\StaticEventCollection;
14 protected $appListeners = array();
15 protected $staticListeners = array();
16 protected $viewListener;
18 public function init(Manager $moduleManager)
20 $this->initAutoloader($moduleManager->getOptions()->getApplicationEnv());
23 protected function initAutoloader($env = null)
25 require __DIR__ . '/autoload_register.php';
28 public function getConfig()
30 return new Config(include __DIR__ . '/configs/module.config.php');
33 public function registerApplicationListeners(EventCollection $events, Locator $locator, Config $config)
35 $view = $locator->get('view');
36 $viewListener = $this->getViewListener($view, $config);
37 $events->attachAggregate($viewListener);
40 public function registerStaticListeners(StaticEventCollection $events, Locator $locator, Config $config)
42 $view = $locator->get('view');
43 $viewListener = $this->getViewListener($view, $config);
45 $viewListener->registerStaticListeners($events, $locator);
48 protected function getViewListener($view, $config)
50 if ($this->viewListener instanceof View\Listener) {
51 return $this->viewListener;
54 $viewListener = new View\Listener($view, $config->layout);
55 $viewListener->setDisplayExceptionsFlag($config->display_exceptions);
57 $this->viewListener = $viewListener;