function EntityReferenceFormatterBase::needsEntityLoad

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase::needsEntityLoad()
  2. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase::needsEntityLoad()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase::needsEntityLoad()

Returns whether the entity referenced by an item needs to be loaded.

Parameters

\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $item: The item to check.

Return value

bool TRUE if the entity needs to be loaded.

2 calls to EntityReferenceFormatterBase::needsEntityLoad()
EntityReferenceFormatterBase::prepareView in core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php
Loads the entities referenced in that field across all the entities being viewed.
FileFormatterBase::needsEntityLoad in core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php
Returns whether the entity referenced by an item needs to be loaded.
1 method overrides EntityReferenceFormatterBase::needsEntityLoad()
FileFormatterBase::needsEntityLoad in core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php
Returns whether the entity referenced by an item needs to be loaded.

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php, line 166

Class

EntityReferenceFormatterBase
Parent plugin for entity reference formatters.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

protected function needsEntityLoad(EntityReferenceItem $item) {
    return !$item->hasNewEntity();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.