You are here

protected function FileFormatterBase::needsEntityLoad in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase::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.

Overrides EntityReferenceFormatterBase::needsEntityLoad

1 method overrides FileFormatterBase::needsEntityLoad()
MediaThumbnailFormatter::needsEntityLoad in core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
This has to be overridden because FileFormatterBase expects $item to be of type \Drupal\file\Plugin\Field\FieldType\FileItem and calls isDisplayed() which is not in FieldItemInterface.

File

core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php, line 18

Class

FileFormatterBase
Base class for file formatters.

Namespace

Drupal\file\Plugin\Field\FieldFormatter

Code

protected function needsEntityLoad(EntityReferenceItem $item) {
  return parent::needsEntityLoad($item) && $item
    ->isDisplayed();
}