public function RestExport::initDisplay

Overrides DisplayPluginBase::initDisplay

File

drupal/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php, line 75
Contains \Drupal\rest\Plugin\views\display\RestExport.

Class

RestExport
The plugin that handles Data response callbacks for REST resources.

Namespace

Drupal\rest\Plugin\views\display

Code

public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) {
  parent::initDisplay($view, $display, $options);
  $container = drupal_container();
  $negotiation = $container
    ->get('content_negotiation');
  $request = $container
    ->get('request');
  $request_content_type = $negotiation
    ->getContentType($request);

  // Only use the requested content type if it's not 'html'. If it is then
  // default to 'json' to aid debugging.
  // @todo Remove the need for this when we have better content negotiation.
  if ($request_content_type != 'html') {
    $this
      ->setContentType($request_content_type);
  }
  $this
    ->setMimeType($request
    ->getMimeType($this->contentType));
}