function EntityViewDisplay::getRenderer

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php \Drupal\Core\Entity\Entity\EntityViewDisplay::getRenderer()
  2. 10 core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php \Drupal\Core\Entity\Entity\EntityViewDisplay::getRenderer()
  3. 11.x core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php \Drupal\Core\Entity\Entity\EntityViewDisplay::getRenderer()

Overrides EntityDisplayInterface::getRenderer

1 call to EntityViewDisplay::getRenderer()
EntityViewDisplay::buildMultiple in core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
Builds a renderable array for the components of a set of entities.

File

core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php, line 195

Class

EntityViewDisplay
Configuration entity.

Namespace

Drupal\Core\Entity\Entity

Code

public function getRenderer($field_name) {
    if (isset($this->plugins[$field_name])) {
        return $this->plugins[$field_name];
    }
    // Instantiate the formatter object from the stored display properties.
    if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) {
        $formatter = $this->pluginManager
            ->getInstance([
            'field_definition' => $definition,
            'view_mode' => $this->originalMode,
            // No need to prepare, defaults have been merged in setComponent().
'prepare' => FALSE,
            'configuration' => $configuration,
        ]);
    }
    else {
        $formatter = NULL;
    }
    // Persist the formatter object.
    $this->plugins[$field_name] = $formatter;
    return $formatter;
}

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