X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=module%2FApplication%2FModule.php;h=7786cd84887ed5d10b0a33571b19785831c1c91f;hb=9616c47598a99e9027530f4f330bb312daa4f136;hp=0b428d0eedc51fb54722fc380b897216978023ef;hpb=20820c4aa92f9272b7c61aa578b331e7b10a829f;p=zf2.biz%2Fgalerie.git diff --git a/module/Application/Module.php b/module/Application/Module.php index 0b428d0..7786cd8 100644 --- a/module/Application/Module.php +++ b/module/Application/Module.php @@ -1,28 +1,35 @@ getApplication()->getServiceManager()->get('translator'); + $eventManager = $e->getApplication()->getEventManager(); + $moduleRouteListener = new ModuleRouteListener(); + $moduleRouteListener->attach($eventManager); + } - public function init(Manager $moduleManager) + public function getConfig() { - $events = StaticEventManager::getInstance(); - $events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100); + return include __DIR__ . '/config/module.config.php'; } public function getAutoloaderConfig() { return array( - 'Zend\Loader\ClassMapAutoloader' => array( - __DIR__ . '/autoload_classmap.php', - ), 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, @@ -30,64 +37,4 @@ class Module implements AutoloaderProvider ), ); } - - public function getConfig() - { - return include __DIR__ . '/config/module.config.php'; - } - - public function initializeView($e) - { - $app = $e->getParam('application'); - $locator = $app->getLocator(); - $config = $e->getParam('config'); - $view = $this->getView($app); - $viewListener = $this->getViewListener($view, $config); - $app->events()->attachAggregate($viewListener); - $events = StaticEventManager::getInstance(); - $viewListener->registerStaticListeners($events, $locator); - } - - protected function getViewListener($view, $config) - { - if ($this->viewListener instanceof View\Listener) { - return $this->viewListener; - } - - $viewListener = new View\Listener($view, $config->layout); - $viewListener->setDisplayExceptionsFlag($config->display_exceptions); - - $this->viewListener = $viewListener; - return $viewListener; - } - - protected function getView($app) - { - if ($this->view) { - return $this->view; - } - - $locator = $app->getLocator(); - $view = $locator->get('view'); - $url = $view->plugin('url'); - $url->setRouter($app->getRouter()); - - $view->plugin('doctype')->setDoctype('HTML5'); - - $view->plugin('headTitle')->setSeparator(' - ') - ->setAutoEscape(false) - ->append('ZF2 Skeleton Application'); - - $basePath = $app->getRequest()->getBaseUrl(); - - $view->plugin('headLink')->appendStylesheet($basePath . '/css/bootstrap.min.css'); - - $html5js = ''; - $view->plugin('placeHolder')->__invoke('html5js')->set($html5js); - $favicon = ''; - $view->plugin('placeHolder')->__invoke('favicon')->set($favicon); - - $this->view = $view; - return $view; - } }