class EntityReferenceTaxonomyTermRssFormatter
Same name in other branches
- 9 core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter
- 8.9.x core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter
- 10 core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter
Plugin implementation of the 'entity reference taxonomy term RSS' formatter.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\Field\PluginSettingsBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface
- class \Drupal\Core\Field\FormatterBase extends \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\FormatterInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase extends \Drupal\Core\Field\FormatterBase
- class \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter extends \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase
- class \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase extends \Drupal\Core\Field\FormatterBase
- class \Drupal\Core\Field\FormatterBase extends \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\FormatterInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Field\PluginSettingsBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of EntityReferenceTaxonomyTermRssFormatter
File
-
core/
modules/ taxonomy/ src/ Plugin/ Field/ FieldFormatter/ EntityReferenceTaxonomyTermRssFormatter.php, line 15
Namespace
Drupal\taxonomy\Plugin\Field\FieldFormatterView source
class EntityReferenceTaxonomyTermRssFormatter extends EntityReferenceFormatterBase {
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public static function isApplicable(FieldDefinitionInterface $field_definition) {
// This formatter is only available for taxonomy terms.
return $field_definition->getFieldStorageDefinition()
->getSetting('target_type') == 'taxonomy_term';
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.