Commit 7b12ed6f authored by Crell's avatar Crell

Switch to the new JsonResponse object in the View subscriber, too.

parent a2f83000
......@@ -3,6 +3,7 @@
namespace Drupal\Core\EventSubscriber;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -30,14 +31,6 @@ public function __construct(ContentNegotiation $negotiation) {
$this->negotiation = $negotiation;
}
protected function createJsonResponse() {
$response = new Response();
$response->headers->set('Content-Type', 'application/json; charset=utf-8');
return $response;
}
/**
* Processes a successful controller into an HTTP 200 response.
*
......@@ -67,9 +60,9 @@ public function onView(GetResponseEvent $event) {
public function onJson(GetResponseEvent $event) {
$page_callback_result = $event->getControllerResult();
print_r($page_callback_result);
//print_r($page_callback_result);
$response = $this->createJsonResponse();
$response = new JsonResponse();
$response->setContent($page_callback_result);
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