You are here

public function ActionLinkTypeBase::getAsLink in Flag 8.4

Get the action link as a Link object.

Parameters

\Drupal\flag\FlagInterface $flag: The flag entity.

\Drupal\Core\Entity\EntityInterface $entity: The flaggable entity.

Return value

\Drupal\Core\Link The action Link.

Overrides ActionLinkTypePluginInterface::getAsLink

File

src/ActionLink/ActionLinkTypeBase.php, line 85

Class

ActionLinkTypeBase
Provides a base class for all link types.

Namespace

Drupal\flag\ActionLink

Code

public function getAsLink(FlagInterface $flag, EntityInterface $entity) {
  $action = $this
    ->getAction($flag, $entity);
  $url = $this
    ->getUrl($action, $flag, $entity);
  $url
    ->setOption('query', [
    'destination' => $this
      ->getDestination(),
  ]);
  $title = $flag
    ->getShortText($action);
  return Link::fromTextAndUrl($title, $url);
}