public function TermName::getItems in Drupal 9
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/Plugin/views/field/TermName.php \Drupal\taxonomy\Plugin\views\field\TermName::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 EntityField::getItems
File
- core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php, line 21
Class
- TermName
- Displays taxonomy term names and allows converting spaces to hyphens.
Namespace
Drupal\taxonomy\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
$items = parent::getItems($values);
if ($this->options['convert_spaces']) {
foreach ($items as &$item) {
// Replace spaces with hyphens.
$name = $item['raw']
->get('value')
->getValue();
// @todo Add link support https://www.drupal.org/node/2567745
$item['rendered']['#context']['value'] = str_replace(' ', '-', $name);
}
}
return $items;
}