Пример #1
0
 public function after()
 {
     $this->prepareViewBeforeRendering();
     //var_dump($this->view->pageTitle);exit;
     $this->response->body = $this->view->render();
     parent::after();
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function after()
 {
     $this->response->setHeader('Content-Type', $this->responseFormat . '; charset=utf-8');
     if ($this->request->method == 'HEAD') {
         $this->response->body = '';
         return;
     }
     if ($this->response->body instanceof Model) {
         /** @var Model $tmpData */
         $tmpData = $this->response->body;
         $tmpData = $tmpData->as_array();
         foreach ($tmpData as $key => $field) {
             if (!in_array($key, $this->exposedFields()) && $key != $this->model->id_field) {
                 unset($tmpData[$key]);
             }
         }
         $this->response->body = $tmpData;
     }
     if ($this->isCollectionRequested) {
         $this->response->body = array_merge(['data' => $this->response->body], $this->meta);
     }
     if ($this->responseFormat == self::FORMAT_XML) {
         $this->response->body = $this->asXML(is_array($this->response->body) ? $this->response->body : []);
     } else {
         $this->response->body = $this->response->body || is_array($this->response->body) ? json_encode($this->response->body) : '';
     }
     if (!is_string($this->response->body)) {
         $this->response->body = (string) $this->response->body;
     }
     //file_put_contents(__DIR__.'/../../../rest.log', date('Y-m-d H:i:s') . "\n" . $this->response->body . "\n\n\n", FILE_APPEND);
     if (!$this instanceof ErrorController) {
         parent::after();
     }
 }
Пример #3
0
 public function after()
 {
     $this->response->body = $this->view->render();
     parent::after();
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function after()
 {
     $this->response->setHeader('Content-Type', $this->responseFormat . '; charset=utf-8');
     if ($this->request->method == 'HEAD') {
         $this->response->body = '';
         return;
     }
     if ($this->response->body instanceof Model) {
         /** @var Model $tmpData */
         $tmpData = $this->response->body;
         $tmpData = $tmpData->as_array();
         foreach ($tmpData as $key => $field) {
             if (!in_array($key, $this->exposedFields()) && $key != $this->model->id_field) {
                 unset($tmpData[$key]);
             }
         }
         $this->response->body = $tmpData;
     }
     if ($this->responseFormat == self::FORMAT_XML) {
         $this->response->body = $this->asXML(is_array($this->response->body) ? $this->response->body : []);
         // echo $this->response->body;exit;
     } else {
         $this->response->body = $this->response->body || is_array($this->response->body) ? json_encode($this->response->body) : '';
     }
     if (!is_string($this->response->body)) {
         $this->response->body = (string) $this->response->body;
     }
     if (!$this instanceof ErrorController) {
         parent::after();
     }
 }