public function EntityFieldExport::renderItems in REST Views 8
Same name and namespace in other branches
- 2.0.x src/Plugin/views/field/EntityFieldExport.php \Drupal\rest_views\Plugin\views\field\EntityFieldExport::renderItems()
Throws
\Exception
Overrides EntityField::renderItems
File
- src/
Plugin/ views/ field/ EntityFieldExport.php, line 21
Class
- EntityFieldExport
- Display entity field data in a serialized display.
Namespace
Drupal\rest_views\Plugin\views\fieldCode
public function renderItems($items) {
if (!empty($items)) {
$items = $this
->prepareItemsByDelta($items);
// Render only those items that are renderable arrays.
foreach ($items as $i => $item) {
if (is_array($items[$i])) {
$items[$i] = $this->renderer
->render($item);
}
}
$data = $this->multiple ? $items : reset($items);
}
else {
// Render an empty field as an empty array or a null value.
$data = $this->multiple ? [] : NULL;
}
// Wrap the output in a data object to protect it from rendering.
return SerializedData::create($data);
}