/**
  * Perform action on this view.
  *
  * @throws Phoenix\Exceptions\WarningException
  * @return void
  */
 private function performViewAction()
 {
     /*
      * ($this->response == null) means that cotroller does not throw any exception and everything is ok
      *
      * ($this->response == Response && $this->response->getException() == NoticeException) means that controller
      * throws NoticeException
      *
      * it is possible to create new response with content only in situations mentioned above
      */
     $action_name = $this->request->getUrl()->getQueryParameter(self::URL_GET_ACTION);
     if (is_null($this->response) || $this->response instanceof Response && $this->response->getException() instanceof NoticeException) {
         if (System::isCallable($this->view, $action_name)) {
             $old_exception = $this->response instanceof Response && $this->response->getException() instanceof NoticeException ? $this->response->getException() : null;
             $this->view->{$action_name}();
             $this->response = $this->view->getResponse();
             $this->response->setException($old_exception);
         } else {
             throw new WarningException(FrameworkExceptions::W_ROUTER_INVALID_ACTION, json_encode($this->request));
         }
     }
 }
示例#2
0
 /**
  * Index view constructor.
  *
  * @param Phoenix\Core\Model $model            
  * @param Phoenix\Http\Request $request            
  * @param Phoenix\Utils\TemplateData $template_data
  *            [optional] default is null
  */
 public function __construct(Model $model, Request $request, TemplateData $template_data = null)
 {
     parent::__construct($model, $request);
     $this->teplate_data = empty($template_data) ? new TemplateData() : $template_data;
 }