You are here

protected function ActionLinkTypeBase::getAction in Flag 8.4

Helper method to get the next flag action the user can take.

Parameters

string $action: The action, flag or unflag.

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

Return value

string

2 calls to ActionLinkTypeBase::getAction()
ActionLinkTypeBase::getAsFlagLink in src/ActionLink/ActionLinkTypeBase.php
Get the action link formatted for use in entity links.
ActionLinkTypeBase::getAsLink in src/ActionLink/ActionLinkTypeBase.php
Get the action link as a Link object.

File

src/ActionLink/ActionLinkTypeBase.php, line 146

Class

ActionLinkTypeBase
Provides a base class for all link types.

Namespace

Drupal\flag\ActionLink

Code

protected function getAction(FlagInterface $flag, EntityInterface $entity) {
  return $flag
    ->isFlagged($entity) ? 'unflag' : 'flag';
}