public function Field::getItems in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field::getItems()
Gets an array of items for the field.
Parameters
\Drupal\views\ResultRow $values: The result row object containing the values.
Return value
array An array of items for the field.
Overrides MultiItemsFieldHandlerInterface::getItems
2 calls to Field::getItems()
- Depth::getItems in core/
modules/ comment/ src/ Plugin/ views/ field/ Depth.php - Gets an array of items for the field.
- TermName::getItems in core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php - Gets an array of items for the field.
2 methods override Field::getItems()
- Depth::getItems in core/
modules/ comment/ src/ Plugin/ views/ field/ Depth.php - Gets an array of items for the field.
- TermName::getItems in core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php - Gets an array of items for the field.
File
- core/
modules/ views/ src/ Plugin/ views/ field/ Field.php, line 806 - Contains \Drupal\views\Plugin\views\field\Field.
Class
- Field
- A field that displays entity field data.
Namespace
Drupal\views\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
if (!$this->displayHandler
->useGroupBy()) {
$build_list = $this
->getEntityFieldRenderer()
->render($values, $this);
}
else {
// For grouped results we need to retrieve a massaged entity having
// grouped field values to ensure that "grouped by" values, especially
// those with multiple cardinality work properly. See
// \Drupal\views\Tests\QueryGroupByTest::testGroupByFieldWithCardinality.
$display = [
'type' => $this->options['type'],
'settings' => $this->options['settings'],
'label' => 'hidden',
];
$build_list = $this
->createEntityForGroupBy($this
->getEntity($values), $values)->{$this->definition['field_name']}
->view($display);
}
if (!$build_list) {
return [];
}
if ($this->options['field_api_classes']) {
return [
[
'rendered' => $this->renderer
->render($build_list),
],
];
}
// Render using the formatted data itself.
$items = [];
// Each item is extracted and rendered separately, the top-level formatter
// render array itself is never rendered, so we extract its bubbleable
// metadata and add it to each child individually.
$bubbleable = BubbleableMetadata::createFromRenderArray($build_list);
foreach (Element::children($build_list) as $delta) {
BubbleableMetadata::createFromRenderArray($build_list[$delta])
->merge($bubbleable)
->applyTo($build_list[$delta]);
$items[$delta] = [
'rendered' => $build_list[$delta],
// Add the raw field items (for use in tokens).
'raw' => $build_list['#items'][$delta],
];
}
return $items;
}