Exemplo n.º 1
0
 /**
  * Register the services.
  *
  * @throws Exception
  * @return void
  */
 public function registerServices()
 {
     if (empty($this->_moduleName)) {
         $class = new \ReflectionClass($this);
         throw new \Exception('Bootstrap has no module name: ' . $class->getFileName());
     }
     $di = $this->getDI();
     $config = $this->getConfig();
     $eventsManager = $this->getEventsManager();
     $moduleDirectory = $this->getModuleDirectory();
     /*************************************************/
     //  Initialize view.
     /*************************************************/
     $di->set('view', function () use($di, $config, $moduleDirectory, $eventsManager) {
         return View::factory($di, $config, $moduleDirectory . '/View/', $eventsManager);
     });
     /*************************************************/
     //  Initialize dispatcher.
     /*************************************************/
     $eventsManager->attach('dispatch:beforeException', new DispatchErrorHandler());
     // Create dispatcher.
     $dispatcher = new Dispatcher();
     $dispatcher->setEventsManager($eventsManager);
     $di->set('dispatcher', $dispatcher);
 }
Exemplo n.º 2
0
 /**
  * Register the services.
  *
  * @throws Exception
  * @return void
  */
 public function initialize()
 {
     if (empty($this->_moduleName)) {
         $class = new \ReflectionClass($this);
         throw new Exception('Bootstrap has no module name: ' . $class->getFileName());
     }
     $di = $this->getDI();
     $config = $this->getConfig();
     $eventsManager = $this->getEventsManager();
     /*************************************************/
     //  Initialize dispatcher.
     /*************************************************/
     $eventsManager->attach("dispatch:beforeException", new DispatchErrorHandler());
     if (!$config->application->debug) {
         $eventsManager->attach('dispatch:beforeExecuteRoute', new CacheAnnotation());
     }
     // Create dispatcher.
     $dispatcher = new Dispatcher();
     $dispatcher->setEventsManager($eventsManager);
     $di->set('dispatcher', $dispatcher);
 }