public function FormatterInterface::prepareView

Allows formatters to load information for field values being displayed.

This should be used when a formatter needs to load additional information from the database in order to render a field, for example a reference field that displays properties of the referenced entities such as name or type.

This method is called after the field type's implementation of hook_field_prepare_view().

This method operates on multiple entities. The $entities and $items parameters are arrays keyed by entity ID. For performance reasons, information for all involved entities should be loaded in a single query where possible.

Changes or additions to field values are done by alterings the $items parameter by reference.

Parameters

array $entities: Array of entities being displayed, keyed by entity ID.

string $langcode: The language the field values are to be shown in. If no language is provided the current language is used.

array $items: Array of field values for the entities, keyed by entity ID.

1 method overrides FormatterInterface::prepareView()
FormatterBase::prepareView in drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php
Allows formatters to load information for field values being displayed.

File

drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterInterface.php, line 75
Contains \Drupal\field\Plugin\Type\Formatter\FormatterInterface.

Class

FormatterInterface
Interface definition for field widget plugins.

Namespace

Drupal\field\Plugin\Type\Formatter

Code

public function prepareView(array $entities, $langcode, array &$items);