function EntityField::getEntityFieldRenderer

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getEntityFieldRenderer()
  2. 10 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getEntityFieldRenderer()
  3. 11.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getEntityFieldRenderer()

Returns the entity field renderer.

Return value

\Drupal\views\Entity\Render\EntityFieldRenderer The entity field renderer.

File

core/modules/views/src/Plugin/views/field/EntityField.php, line 801

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

protected function getEntityFieldRenderer() {
    if (!isset($this->entityFieldRenderer)) {
        // This can be invoked during field handler initialization in which case
        // view fields are not set yet.
        if (!empty($this->view->field)) {
            foreach ($this->view->field as $field) {
                // An entity field renderer can handle only a single relationship.
                if ($field->relationship == $this->relationship && isset($field->entityFieldRenderer)) {
                    $this->entityFieldRenderer = $field->entityFieldRenderer;
                    break;
                }
            }
        }
        if (!isset($this->entityFieldRenderer)) {
            $entity_type = $this->entityTypeManager
                ->getDefinition($this->getEntityType());
            $this->entityFieldRenderer = new EntityFieldRenderer($this->view, $this->relationship, $this->languageManager, $entity_type, $this->entityTypeManager, $this->entityRepository);
        }
    }
    return $this->entityFieldRenderer;
}

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