コード例 #1
0
ファイル: Bootstrap.php プロジェクト: nguyenducduy/haraapp
 /**
  * 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);
 }
コード例 #2
0
ファイル: Bootstrap.php プロジェクト: phalconeye/framework
 /**
  * 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);
 }