示例#1
0
 public function __construct(ApiProblem $apiProblem, \Exception $previous = null, array $headers = array(), $code = null)
 {
     $this->apiProblem = $apiProblem;
     $statusCode = $apiProblem->getStatusCode();
     $message = $apiProblem->getTitle();
     parent::__construct($statusCode, $message, $previous, $headers, $code);
 }
示例#2
0
 public function createResponse(ApiProblem $apiProblem)
 {
     $data = $apiProblem->toArray();
     $response = new JsonResponse($data, $apiProblem->getStatusCode());
     $response->headers->set('Content-Type', 'application/problem+json');
     return $response;
 }
示例#3
0
 public function createResponse(ApiProblem $apiProblem)
 {
     $data = $apiProblem->toArray();
     /**
      * Provide an url for the error documentation
      * @see: https://tools.ietf.org/html/draft-ietf-appsawg-http-problem-03#section-3
      */
     if ($data['type'] != 'about:blank') {
         $data['type'] = 'http://localhost:8000/docs/errors#' . $data['type'];
     }
     $response = new JsonResponse($data, $apiProblem->getStatusCode());
     $response->headers->set('Content-Type', ApiProblem::CONTENT_TYPE);
     return $response;
 }