Пример #1
0
 /**
  * Run with basic events support
  *
  * @return mixed
  */
 public function run()
 {
     $this->monitor->notify(self::BEFORE);
     $data = $this->call();
     $this->monitor->notify(self::AFTER);
     return $data;
 }
Пример #2
0
 /**
  * Executor
  *
  * @return $this
  */
 public function execute()
 {
     $this->bootstrap();
     $this->monitor->notify(static::BOOTSTRAPPED);
     $this->run();
     $this->monitor->notify(static::RUNNING);
     return $this;
 }
Пример #3
0
 /**
  * Dispatch specified route
  *
  * @param mixed $route Route object or name
  *
  * @return Response
  * @throws \Exception
  */
 public function dispatch($route)
 {
     $this->monitor->notify(self::STARTED);
     $response = null;
     $view = null;
     try {
         $this->forceRoute($route);
         $this->monitor->notify(self::ROUTE_FOUND);
         $response = new Response();
         $this->app->getConfig()->grab('response')->inject($response);
         $this->response = $response;
         $this->monitor->notify(self::RESPONSE_CREATED);
         $view = new View($this->app);
         $this->app->getConfig()->grab('view')->inject($view);
         $template = $this->getTemplatePath();
         $view->setTemplate($template);
         $this->view = $view;
         $this->monitor->notify(self::VIEW_CREATED);
         $this->runModule();
         $this->invokeControl();
         $view->addData($this->getData());
         $this->monitor->notify(self::ACTION_INVOKED);
         if ($this->autoRender && !$response->hasContent()) {
             $content = $view->render();
             $response->setContent($content);
         }
         $this->monitor->notify(self::RESPONSE_PROCESSED);
     } catch (\Exception $e) {
         // Clean buffers for sure
         if ($response !== null) {
             $response->clean();
         }
         // Prevent nested exceptions
         if ($this->exception !== null) {
             throw $e;
         } else {
             $this->exception = $e;
         }
         // Create proper response
         $this->monitor->notify(self::EXCEPTION_CAUGHT);
         $response = $this->app->getErrorHandler()->react($e);
         $this->monitor->notify(self::EXCEPTION_HANDLED);
     }
     $this->monitor->notify(self::ENDED);
     return $response;
 }