You are here

public function Reload::getUrl in Flag 8.4

Return a Url object for the given flag action.

Parameters

string $action: The action, flag or unflag.

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

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

Return value

Url The Url object for this plugin's flag/unflag route.

Overrides ActionLinkTypeBase::getUrl

File

src/Plugin/ActionLink/Reload.php, line 21

Class

Reload
Provides the Normal Link (Reload) link type.

Namespace

Drupal\flag\Plugin\ActionLink

Code

public function getUrl($action, FlagInterface $flag, EntityInterface $entity) {
  switch ($action) {
    case 'flag':
      return Url::fromRoute('flag.action_link_flag', [
        'flag' => $flag
          ->id(),
        'entity_id' => $entity
          ->id(),
      ]);
    default:
      return Url::fromRoute('flag.action_link_unflag', [
        'flag' => $flag
          ->id(),
        'entity_id' => $entity
          ->id(),
      ]);
  }
}