Working view layer integration
[zf2.biz/application_blanche.git] / module / Application / Module.php
1 <?php
2
3 namespace Application;
4
5 use Zend\Module\Manager,
6     Zend\EventManager\StaticEventManager,
7     Zend\Module\Consumer\AutoloaderProvider;
8
9 class Module implements AutoloaderProvider
10 {
11     protected $view;
12     protected $viewListener;
13
14     public function init(Manager $moduleManager)
15     {
16         $events = StaticEventManager::getInstance();
17         $events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100);
18     }
19
20     public function getAutoloaderConfig()
21     {
22         return array(
23             'Zend\Loader\ClassMapAutoloader' => array(
24                 __DIR__ . '/autoload_classmap.php',
25             ),
26             'Zend\Loader\StandardAutoloader' => array(
27                 'namespaces' => array(
28                     __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
29                 ),
30             ),
31         );
32     }
33
34     public function getConfig()
35     {
36         return include __DIR__ . '/config/module.config.php';
37     }
38     
39     public function initializeView($e)
40     {
41         $app          = $e->getParam('application');
42         $basePath     = $app->getRequest()->getBasePath();
43         $locator      = $app->getLocator();
44         $renderer     = $locator->get('Zend\View\Renderer\PhpRenderer');
45         $renderer->plugin('url')->setRouter($app->getRouter());
46         $renderer->doctype()->setDoctype('HTML5');
47         $renderer->plugin('basePath')->setBasePath($basePath);
48     }
49 }