diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/Data.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/Data.php index d10ac75..c038810 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/Data.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Data.php @@ -95,8 +95,12 @@ public function getContentType() { return $this->contentType; } - // Return the content type from the request object. - return drupal_container()->get('request')->headers->get('Content-type'); + // Return the content type based on the request object. + $negotiation = drupal_container()->get('content_negotiation'); + $request = drupal_container()->get('request'); + $content_type = $negotiation->getContentType($request); + + return $request->getMimeType($content_type); } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/row/DataFieldRow.php b/core/modules/views/lib/Drupal/views/Plugin/views/row/DataFieldRow.php index bbd0aa7..84031d2 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/row/DataFieldRow.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/row/DataFieldRow.php @@ -40,6 +40,11 @@ class DataFieldRow extends RowPluginBase { public function init(ViewExecutable $view, &$display, $options = NULL) { parent::init($view, $display, $options); + + if (!empty($this->options['aliases'])) { + // Prepare a trimmed version of replacement aliases. + $this->replacementAliases = array_map('trim', (array) $this->options['aliases']); + } } /** @@ -88,8 +93,6 @@ public function validateOptionsForm(&$form, &$form_state) { form_set_error('aliases', t('All field aliases must be unique')); } - // Prepare a trimmed version of replacement aliases. - $form_state['values']['row_options']['aliases'] = array_map('trim', (array) $form_state['values']['row_options']['aliases']); } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/style/Serialize.php b/core/modules/views/lib/Drupal/views/Plugin/views/style/Serialize.php index 010c876..344b15b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/style/Serialize.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/Serialize.php @@ -38,20 +38,25 @@ class Serialize extends StylePluginBase { * Overrides Drupal\views\Plugin\views\style\StylePluginBase::render(). */ public function render() { - // Get the Serializer service. + // Get services for serialization. $serializer = drupal_container()->get('serializer'); - $rows = array(); + $request = drupal_container()->get('request'); + $negotiation = drupal_container()->get('content_negotiation'); + $rows = array(); // If the Data Entity row plugin is used, this will be an array of entities // which will pass through Serializer to one of the registered Normalizers, - // which will transform it to arrays/scalars. If the Data Field row plugin + // which will transform it to arrays/scalars. If the Data field row plugin // is used, $rows will not contain objects and will pass directly to the // Encoder. foreach ($this->view->result as $row) { $rows[] = $this->row_plugin->render($row); } - return $serializer->serialize($rows, drupal_container()->get('request')->headers->get('Content-type')); + $content_type = $negotiation->getContentType($request); + $this->displayHandler->setContentType($request->getMimeType($content_type)); + + //return $serializer->serialize($rows, $content_type); } }