Example #1
0
 /**
  * @param Response $response
  * @param $model
  * @return mixed
  */
 public function __invoke(Response $response, $model = null)
 {
     !$model && ($model = $response->content());
     if (!$model instanceof ViewModel) {
         return $model;
     }
     try {
         $response->setContent($this->render($model));
     } catch (Exception $exception) {
         $response->setContent($this->exception($exception));
     }
     return $response;
 }
Example #2
0
 /**
  * @param ExceptionInterface $exception
  * @param Response $response
  * @return Response
  */
 public function __invoke(ExceptionInterface $exception, Response $response)
 {
     $response->setContent($this->exception($exception));
     return $response;
 }
Example #3
0
 /**
  * @param \Exception $exception
  * @param Response $response
  * @return Model
  */
 public function __invoke(\Exception $exception, Response $response)
 {
     $response->setStatus(500);
     return $this->model([ExceptionModel::EXCEPTION => $exception]);
 }
Example #4
0
 /**
  * @param Response $response
  * @return ErrorModel
  */
 public function __invoke(Response $response)
 {
     $response->setStatus(404);
     return $this->model();
 }
Example #5
0
 /**
  * @param Response $response
  * @return Response
  */
 public function __invoke(Response $response)
 {
     $response->setStatus($this->status);
     return $response;
 }