You are here

protected function EntityField::getEntityFieldRenderer in Drupal 8

Same name and namespace in other branches
  1. 9 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 814

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