You are here

protected function Field::getEntityFieldRenderer in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field::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/Field.php, line 776
Contains \Drupal\views\Plugin\views\field\Field.

Class

Field
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->entityManager
        ->getDefinition($this
        ->getEntityType());
      $this->entityFieldRenderer = new EntityFieldRenderer($this->view, $this->relationship, $this->languageManager, $entity_type, $this->entityManager);
    }
  }
  return $this->entityFieldRenderer;
}