You are here

public function EntityReferenceIdFormatter::viewElements in Entity reference 8

Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().

Overrides EntityReferenceFormatterBase::viewElements

File

lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceIdFormatter.php, line 34
Definition of Drupal\entityreference\Plugin\field\formatter\EntityReferenceIdFormatter.

Class

EntityReferenceIdFormatter
Plugin implementation of the 'entity-reference ID' formatter.

Namespace

Drupal\entityreference\Plugin\field\formatter

Code

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;
}