You are here

public function FlagViewsLinkField::getFlag in Flag 8.4

A helper method to retrieve the flag entity from the views relationship.

Return value

\Drupal\flag\FlagInterface|null The flag selected by the views relationship.

File

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

Class

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

Namespace

Drupal\flag\Plugin\views\field

Code

public function getFlag() {
  if ($this->flag) {
    return $this->flag;
  }
  elseif (isset($this->view->relationship[$this->options['relationship']])) {
    return $this->view->relationship[$this->options['relationship']]
      ->getFlag();
  }
  return NULL;
}