You are here

protected function CumulativeField::getRelationshipEntity in Views Cumulative Field 8

Parameters

$values:

$field:

$relationship:

Return value

\Drupal\Core\Entity\EntityInterface|null

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to CumulativeField::getRelationshipEntity()
CumulativeField::getValue in src/Plugin/views/field/CumulativeField.php
Gets the value that's supposed to be rendered.

File

src/Plugin/views/field/CumulativeField.php, line 144
Defines Drupal\views_cumulative_field\Plugin\views\field\CumulativeField.

Class

CumulativeField
Field handler to flag the node type.

Namespace

Drupal\views_cumulative_field\Plugin\views\field

Code

protected function getRelationshipEntity($values, $field, $relationship) {
  $relationship_entity = NULL;

  // Get the entity type of the relationship.
  $relationship_entity_type = $this->displayHandler
    ->getHandler('field', $field)
    ->getEntityType();
  $relationship_entities = $values->_relationship_entities;

  // First check the referenced entity.
  if (isset($relationship_entities[$relationship])) {

    // Get the id of the relationship entity.
    $entity_id = $relationship_entities[$relationship]
      ->id();

    // Get the data of the relationship entity.
    $relationship_entity = $this->entityTypeManager
      ->getStorage($relationship_entity_type)
      ->load($entity_id);
  }
  return $relationship_entity;
}