Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityField.php

function 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 837

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal