public function Serializer::render in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/Plugin/views/style/Serializer.php \Drupal\rest\Plugin\views\style\Serializer::render()
Render the display in this style.
Overrides StylePluginBase::render
File
- core/
modules/ rest/ src/ Plugin/ views/ style/ Serializer.php, line 117 - Contains \Drupal\rest\Plugin\views\style\Serializer.
Class
- Serializer
- The style plugin for serialized output formats.
Namespace
Drupal\rest\Plugin\views\styleCode
public function render() {
$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
// is used, $rows will not contain objects and will pass directly to the
// Encoder.
foreach ($this->view->result as $row_index => $row) {
$this->view->row_index = $row_index;
$rows[] = $this->view->rowPlugin
->render($row);
}
unset($this->view->row_index);
// Get the content type configured in the display or fallback to the
// default.
if (empty($this->view->live_preview)) {
$content_type = $this->displayHandler
->getContentType();
}
else {
$content_type = !empty($this->options['formats']) ? reset($this->options['formats']) : 'json';
}
return $this->serializer
->serialize($rows, $content_type);
}