Example #1
0
 /**
  * @param View|array|string $response
  *
  * @throws Exception
  */
 public function setResponse($response)
 {
     if (!$this->is_rest) {
         $this->response->setSecurityHeaders();
     }
     if ($response instanceof View && $this->response_type == 'html' && !$this->is_rest) {
         $this->response->raw($response->render());
     } elseif ($this->is_rest || $this->response_type == 'json' || is_array($response) || is_object($response) && !$response instanceof View) {
         if ($response instanceof View) {
             throw new Exception(translate('Response can not be a instance of cordillera\\middlewares\\View object'), 500, Exception::BADARGUMENTS);
         }
         $this->response->json($response);
     }
 }