You are here

public function FieldPluginBase::getEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getEntity()

Gets the entity matching the current row and relationship.

Parameters

\Drupal\views\ResultRow $values: An object containing all retrieved values.

Return value

\Drupal\Core\Entity\EntityInterface|null Returns the entity matching the values or NULL if there is no matching entity.

Overrides FieldHandlerInterface::getEntity

17 calls to FieldPluginBase::getEntity()
BulkForm::viewsForm in core/modules/views/src/Plugin/views/field/BulkForm.php
Form constructor for the bulk form.
CommentedEntity::getItems in core/modules/comment/src/Plugin/views/field/CommentedEntity.php
Gets an array of items for the field.
ContactLink::renderLink in core/modules/contact/src/Plugin/views/field/ContactLink.php
Prepares the link to view a entity.
EntityField::getItems in core/modules/views/src/Plugin/views/field/EntityField.php
Gets an array of items for the field.
EntityField::getValue in core/modules/views/src/Plugin/views/field/EntityField.php
Gets the value that's supposed to be rendered.

... See full list

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 402

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function getEntity(ResultRow $values) {
  $relationship_id = $this->options['relationship'];
  if ($relationship_id == 'none') {
    return $values->_entity;
  }
  elseif (isset($values->_relationship_entities[$relationship_id])) {
    return $values->_relationship_entities[$relationship_id];
  }
}