X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=module%2FApplication%2FModule.php;h=a540a11f8d7d3f544843c47060db1cd6520438ed;hb=7a482c8f4e56f572888c780da6c1912facd26850;hp=a7986681acbae77253bbace0ffbb105ff37b1c8c;hpb=ab145e65efd803ce0fc2e3264d80b74217f67d97;p=zf2.biz%2Fgalerie.git diff --git a/module/Application/Module.php b/module/Application/Module.php index a798668..a540a11 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->getSharedCollections(); + $sharedEvents->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100); } public function getAutoloaderConfig() @@ -39,45 +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'); - - // Set up view helpers - $view->plugin('url')->setRouter($app->getRouter()); - $view->doctype()->setDoctype('HTML5'); - - $basePath = $app->getRequest()->getBaseUrl(); - $view->plugin('basePath')->setBasePath($basePath); - - $this->view = $view; - return $view; + $renderer = $locator->get('Zend\View\Renderer\PhpRenderer'); + $renderer->plugin('basePath')->setBasePath($basePath); } }