function EntityReferenceTaxonomyTermRssFormatter::viewElements
Same name in other branches
- 9 core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter::viewElements()
- 8.9.x core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter::viewElements()
- 10 core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter::viewElements()
Overrides FormatterInterface::viewElements
File
-
core/
modules/ taxonomy/ src/ Plugin/ Field/ FieldFormatter/ EntityReferenceTaxonomyTermRssFormatter.php, line 28
Class
- EntityReferenceTaxonomyTermRssFormatter
- Plugin implementation of the 'entity reference taxonomy term RSS' formatter.
Namespace
Drupal\taxonomy\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$parent_entity = $items->getEntity();
$elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $entity) {
$parent_entity->rss_elements[] = [
'key' => 'category',
'value' => $entity->label(),
'attributes' => [
'domain' => $entity->id() ? Url::fromRoute('entity.taxonomy_term.canonical', [
'taxonomy_term' => $entity->id(),
], [
'absolute' => TRUE,
])
->toString() : '',
],
];
}
return $elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.