/**
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $request = $event->getRequest();
     $acceptHeader = $request->headers->get('Accept', '*/*');
     if (!$this->contentTypeMatcher->matches($acceptHeader, $this->handledContentTypes)) {
         return;
     }
     $exception = $event->getException();
     $data = $this->exceptionTransformer->transformException($exception);
     $status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;
     $event->setResponse(new JsonResponse($data, $status));
 }
 /**
  * @param Request $request
  */
 public function decodeBody(Request $request)
 {
     $acceptHeader = $request->headers->get('Content-Type', '*/*');
     if (!$this->contentTypeMatcher->matches($acceptHeader, $this->contentTypes)) {
         return;
     }
     $jsonBody = $request->getContent(false);
     $decodedBody = json_decode($jsonBody, true);
     if (!is_array($decodedBody)) {
         $decodedBody = array();
     }
     $request->request->replace($decodedBody);
 }
 public function testMatchEmptyContentTypeReturnsFalse()
 {
     $matcher = new ContentTypeMatcher();
     $this->assertFalse($matcher->matches('', array('text/html')));
 }