You are here

public function EntityReferenceFormatterBase::viewElements in Entity reference 8

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

Remove unaccessible values.

See also

Drupal\entityreference\Plugin\field\formatter\EntityReferenceFormatterBase::prepareView().

2 calls to EntityReferenceFormatterBase::viewElements()
EntityReferenceEntityFormatter::viewElements in lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceEntityFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
EntityReferenceLabelFormatter::viewElements in lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceLabelFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
3 methods override EntityReferenceFormatterBase::viewElements()
EntityReferenceEntityFormatter::viewElements in lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceEntityFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
EntityReferenceIdFormatter::viewElements in lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceIdFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
EntityReferenceLabelFormatter::viewElements in lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceLabelFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().

File

lib/Drupal/entityreference/Plugin/field/formatter/EntityReferenceFormatterBase.php, line 81
Definition of Drupal\entityreference\Plugin\field\formatter\EntityReferenceFormatterBase.

Class

EntityReferenceFormatterBase
Parent plugin for entity-reference formatters.

Namespace

Drupal\entityreference\Plugin\field\formatter

Code

public function viewElements(EntityInterface $entity, $langcode, array $items) {

  // Remove unaccessible items.
  foreach ($items as $delta => $item) {
    if (empty($item['access'])) {
      unset($items[$delta]);
    }
  }
  return array();
}