コード例 #1
0
ファイル: View.php プロジェクト: p-m-d/naf-action
 public function __construct($request = null, $response = null, $options = array())
 {
     $this->viewConfig(Config::merge(self::$view, static::$view, $options));
     $this->request = $request ?: Action::request();
     $this->response = $response ?: Action::response();
     if (isset($this->viewConfig['type'])) {
         $this->response->type = $this->viewConfig['type'];
     } else {
         $this->viewConfig['type'] = $this->response->type;
     }
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: p-m-d/naf-action
 public function __construct($request = null, $response = null, $name = null)
 {
     $this->viewConfig(static::$view + self::$view);
     $this->request = $request ?: Action::request();
     $this->response = $response ?: Action::response();
     if (!isset($this->name)) {
         if (empty($name)) {
             $classPath = explode('\\', get_class($this));
             $name = preg_replace('/Controller$/', '', end($classPath));
         }
         $this->name = $name;
     }
 }
コード例 #3
0
ファイル: ErrorHandler.php プロジェクト: p-m-d/naf-action
 public function renderException($self, $params, $chain)
 {
     if (ob_get_length()) {
         ob_end_clean();
     }
     extract($params);
     $request = end(Action::$requests) ?: Action::request();
     $response = Action::response();
     if (!Config::get('debug')) {
         if ($exception instanceof ActionException) {
             $response->status = $exception->getStatus();
         }
     }
     $errorController = new Controller($request, $response);
     $errorController->overload('error', function ($self) {
         return $self->render();
     });
     $view = ['view' => Config::get('debug') ? 'debug_exception' : 'error', 'view_path' => 'Error'];
     $data = compact('exception');
     echo $errorController('error', $data, $view);
     $params['exit'] = true;
     return $chain->next($self, $params, $chain);
 }