diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 629d674..7f42090 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -8,6 +8,7 @@ namespace Drupal\rest\Plugin\views\display; use Drupal\Component\Utility\String; +use Drupal\Core\Render\RendererInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\ContentNegotiation; @@ -95,10 +96,13 @@ class RestExport extends PathPluginBase { * The state key value store. * @param \Drupal\Core\ContentNegotiation $content_negotiation * The content negotiation library. + * @param \Drupal\Core\Render\RendererInterface $renderer + * The renderer service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, StateInterface $state, ContentNegotiation $content_negotiation) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, StateInterface $state, ContentNegotiation $content_negotiation, RendererInterface $renderer) { parent::__construct($configuration, $plugin_id, $plugin_definition, $route_provider, $state); $this->contentNegotiation = $content_negotiation; + $this->renderer = $renderer; } /** @@ -111,7 +115,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $container->get('router.route_provider'), $container->get('state'), - $container->get('content_negotiation') + $container->get('content_negotiation'), + $container->get('renderer') ); } @@ -276,12 +281,12 @@ public function execute() { // In JSONP mode? $callback = $this->view->getRequest()->get('jsonp') ?: $this->view->getRequest()->get('callback'); if ($callback) { - $response = new JsonResponse(drupal_render_root($output), 200, array()); + $response = new JsonResponse($this->renderer->render($output), 200, array()); $response->setCallback($callback); return $response; } - return new Response(drupal_render_root($output), 200, array('Content-type' => $this->getMimeType())); + return new Response($this->renderer->render($output), 200, array('Content-type' => $this->getMimeType())); } /** diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index c31600d..5c16c66 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -44,7 +44,7 @@ public function handle(RouteMatchInterface $route_match, Request $request) { ->get('plugin.manager.rest') ->getInstance(array('id' => $plugin)); - // Deserialze incoming data if available. + // Deserialize incoming data if available. $serializer = $this->container->get('serializer'); $received = $request->getContent(); $unserialized = NULL;