Commit da00dcc3 authored by Crell's avatar Crell

Switch to the new JsonResponse object from Symfony.

parent edcc5bd5
......@@ -10,6 +10,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
......@@ -41,7 +42,7 @@ class ExceptionController {
/**
* Constructor
*
*
* @param HttpKernelInterface $kernel
* The kernel that spawned this controller, so that it can be reused
* for subrequests.
......@@ -169,13 +170,6 @@ public function on404Html(FlattenException $exception, Request $request) {
return $response;
}
protected function createJsonResponse() {
$response = new Response();
$response->headers->set('Content-Type', 'application/json; charset=utf-8');
return $response;
}
/**
* Processes an AccessDenied exception into an HTTP 403 response.
*
......@@ -183,7 +177,7 @@ protected function createJsonResponse() {
* The Event to process.
*/
public function on403Json(FlattenException $exception, Request $request) {
$response = $this->createJsonResponse();
$response = new JsonResponse();
$response->setStatusCode(403, 'Access Denied');
return $response;
}
......@@ -195,7 +189,7 @@ public function on403Json(FlattenException $exception, Request $request) {
* The Event to process.
*/
public function on404Json(FlattenException $exception, Request $request) {
$response = $this->createJsonResponse();
$response = new JsonResponse();
$response->setStatusCode(404, 'Not Found');
return $response;
}
......@@ -207,7 +201,7 @@ public function on404Json(FlattenException $exception, Request $request) {
* The Event to process.
*/
public function on405Json(FlattenException $exception, Request $request) {
$response = $this->createJsonResponse();
$response = new JsonResponse();
$response->setStatusCode(405, 'Method Not Allowed');
return $response;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment