X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=module%2FApplication%2FModule.php;h=0ed2ef2f91e16136acc6958cc00d0e90984a4c77;hb=5aeb655136c743a3b62877b5436a443353f3359e;hp=a7986681acbae77253bbace0ffbb105ff37b1c8c;hpb=ab145e65efd803ce0fc2e3264d80b74217f67d97;p=zf2.biz%2Fgalerie.git diff --git a/module/Application/Module.php b/module/Application/Module.php index a798668..0ed2ef2 100644 --- a/module/Application/Module.php +++ b/module/Application/Module.php @@ -2,82 +2,10 @@ namespace Application; -use Zend\Module\Manager, - Zend\EventManager\StaticEventManager, - Zend\Module\Consumer\AutoloaderProvider; - -class Module implements AutoloaderProvider +class Module { - protected $view; - protected $viewListener; - - public function init(Manager $moduleManager) - { - $events = StaticEventManager::getInstance(); - $events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100); - } - - public function getAutoloaderConfig() - { - return array( - 'Zend\Loader\ClassMapAutoloader' => array( - __DIR__ . '/autoload_classmap.php', - ), - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( - __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); - } - 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'); - - // 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; - } }