You are here

public function FieldEntry::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/FieldEntry.php, line 24

Class

FieldEntry
Class FieldEntry

Namespace

Drupal\flag\Plugin\ActionLink

Code

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