class EntityReferenceIdFormatter in Entity reference 8
Plugin implementation of the 'entity-reference ID' formatter.
Plugin annotation
@Plugin(
id = "entityreference_entity_id",
module = "entityreference",
label = @Translation("Entity ID"),
description = @Translation("Display the ID of the referenced entities."),
field_types = {
"entityreference"
}
)
Hierarchy
- class \Drupal\entityreference\Plugin\field\formatter\EntityReferenceFormatterBase extends \Drupal\field\Plugin\Type\Formatter\FormatterBase
- class \Drupal\entityreference\Plugin\field\formatter\EntityReferenceIdFormatter
Expanded class hierarchy of EntityReferenceIdFormatter
File
- lib/
Drupal/ entityreference/ Plugin/ field/ formatter/ EntityReferenceIdFormatter.php, line 29 - Definition of Drupal\entityreference\Plugin\field\formatter\EntityReferenceIdFormatter.
Namespace
Drupal\entityreference\Plugin\field\formatterView source
class EntityReferenceIdFormatter extends EntityReferenceFormatterBase {
/**
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#markup' => check_plain($item['target_id']),
);
}
return $elements;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityReferenceFormatterBase:: |
public | function | Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::prepareView(). | |
EntityReferenceIdFormatter:: |
public | function |
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements(). Overrides EntityReferenceFormatterBase:: |