You are here

protected function FlagViewsLinkField::renderLink in Flag 8.4

Creates a render array for flag links.

Parameters

EntityInterface $entity: The entity object.

ResultRow $values: The current result row.

Return value

array|string The render array for the flag link.

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

File

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

Class

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

Namespace

Drupal\flag\Plugin\views\field

Code

protected function renderLink(EntityInterface $entity, ResultRow $values) {

  // Output nothing as there is no flag.
  // For an 'empty text' option use the default 'No results behavior'
  // option provided by Views.
  if (empty($entity)) {
    return '';
  }
  return $this->flagLinkBuilder
    ->build($entity
    ->getEntityTypeId(), $entity
    ->id(), $this
    ->getFlag()
    ->id());
}