class EntityReferenceIdFormatter
Same name in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceIdFormatter
- 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceIdFormatter
- 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceIdFormatter
Plugin implementation of the 'entity reference ID' 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\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceIdFormatter 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 EntityReferenceIdFormatter
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldFormatter/ EntityReferenceIdFormatter.php, line 12
Namespace
Drupal\Core\Field\Plugin\Field\FieldFormatterView source
class EntityReferenceIdFormatter extends EntityReferenceFormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
if ($entity->id()) {
$elements[$delta] = [
'#plain_text' => $entity->id(),
// Create a cache tag entry for the referenced entity. In the case
// that the referenced entity is deleted, the cache for referring
// entities must be cleared.
'#cache' => [
'tags' => $entity->getCacheTags(),
],
];
}
}
return $elements;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.