X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=module%2FApplication%2FModule.php;h=5f9342686cc52d54e6f3cbb85ca4faaea28782e2;hb=7889d92c1550c6122119815ad673d186fee4f415;hp=2f20670efaf1060ed4801e64183dcf965ec115b2;hpb=fd9fa76220199fa804876223968dc473bd360179;p=zf2.biz%2Fapplication_blanche.git diff --git a/module/Application/Module.php b/module/Application/Module.php index 2f20670..5f93426 100644 --- a/module/Application/Module.php +++ b/module/Application/Module.php @@ -8,13 +8,11 @@ use Zend\Module\Manager, class Module implements AutoloaderProvider { - protected $view; - protected $viewListener; - public function init(Manager $moduleManager) { - $events = StaticEventManager::getInstance(); - $events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100); + $events = $moduleManager->events(); + $sharedEvents = $events->getSharedManager(); + $sharedEvents->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100); } public function getAutoloaderConfig() @@ -39,53 +37,9 @@ class Module implements AutoloaderProvider public function initializeView($e) { $app = $e->getParam('application'); + $basePath = $app->getRequest()->getBasePath(); $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('headTitle')->setSeparator(' - ') - ->setAutoEscape(false) - ->append('ZF2 Skeleton Application'); - - $basePath = $app->getRequest()->detectBaseUrl(); - - $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; + $renderer = $locator->get('Zend\View\Renderer\PhpRenderer'); + $renderer->plugin('basePath')->setBasePath($basePath); } }