EntityReferenceIdFormatter.php in Entity reference 8
File
lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceIdFormatter.php
View source
<?php
namespace Drupal\entityreference\Plugin\field\formatter;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Entity\EntityInterface;
use Drupal\entityreference\Plugin\field\formatter\EntityReferenceFormatterBase;
class EntityReferenceIdFormatter extends EntityReferenceFormatterBase {
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;
}
}