Ejemplo n.º 1
0
 /**
  * Run proxy detection.
  * 
  * @throws Phoenix\Exceptions\FailureException
  * @return void
  */
 private function runProxy()
 {
     try {
         if ($this->isFrontControllerRequest() === true) {
             $this->performFrontControllerRequest();
             return;
         }
         if ($this->isProxyRequest() === true) {
             $this->performProxyRequest();
         }
     } catch (NoticeException $e) {
         $this->response = ResponseFactory::createResponse($this->response_format);
         $this->response->setException($e);
     } catch (WarningException $e) {
         Logger::log($e, $this->db);
         $this->response = ResponseFactory::createResponse($this->response_format);
         $this->response->setException($e);
     } catch (FailureException $e) {
         Logger::log($e);
         $this->response = ResponseFactory::createResponse($this->response_format);
         $this->response->setException($e);
     } catch (Exception $e) {
         Logger::log($e);
         $this->response = ResponseFactory::createResponse($this->response_format);
         $this->response->setException($e);
     }
 }
Ejemplo n.º 2
0
 /**
  * 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));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * FileResponse constructor.
  *
  * @param Phoenix\Exceptions\BaseException $e
  *            [optional] default null
  */
 public function __construct(BaseException $e = null)
 {
     parent::__construct(Response::S200_OK, self::CONTENT_TYPE_FILE, self::CHARSET_FILE, $e);
 }
Ejemplo n.º 4
0
 /**
  * HtmlResponse constructor.
  *
  * @param string $template_file
  *            [optional] default null
  * @param Phoenix\Utils\TemplateData $template_data
  *            [optional] default null
  * @param Phoenix\Exceptions\BaseException $e
  *            [optional] default null
  */
 public function __construct($template_file = null, TemplateData $template_data = null, BaseException $e = null)
 {
     parent::__construct(Response::S200_OK, self::CONTENT_TYPE_HTML, self::CHARSET_HTML, $e);
     $this->setTemplateData($template_data);
     $this->setTemplateFile($template_file);
 }