You are here

protected function FlagViewsLinkField::getParentRelationshipEntity in Flag 8.4

Returns the entity for this field's relationship's parent relationship.

For example, if this field's flag relationship is itself on a node, then this will return the node entity for the current row.

Parameters

ResultRow $values: The current result row.

Return value

\Drupal\Core\Entity\EntityInterface The parent entity.

1 call to FlagViewsLinkField::getParentRelationshipEntity()
FlagViewsLinkField::render in src/Plugin/views/field/FlagViewsLinkField.php
Renders the field.

File

src/Plugin/views/field/FlagViewsLinkField.php, line 148

Class

FlagViewsLinkField
Provides a views field to flag or unflag the selected content.

Namespace

Drupal\flag\Plugin\views\field

Code

protected function getParentRelationshipEntity(ResultRow $values) {
  $relationship_id = $this->options['relationship'];
  $relationship_handler = $this->view->display_handler->handlers['relationship'][$relationship_id];
  $parent_relationship_id = $relationship_handler->options['relationship'];
  if ($parent_relationship_id == 'none') {
    return $values->_entity;
  }
  elseif (isset($values->_relationship_entities[$parent_relationship_id])) {
    return $values->_relationship_entities[$parent_relationship_id];
  }
}