class ShortcutLinkTarget

Provides a Shortcut link target handler.

Shortcut entities are atypical because they describe a link to elsewhere and don't have a canonical route to view them. So when linking to such an entity, the link target must be their destination.

Hierarchy

Expanded class hierarchy of ShortcutLinkTarget

See also

\Drupal\shortcut\ShortcutInterface::getUrl()

File

core/modules/shortcut/src/Entity/ShortcutLinkTarget.php, line 21

Namespace

Drupal\shortcut\Entity
View source
class ShortcutLinkTarget implements EntityLinkTargetInterface {
  
  /**
   * {@inheritdoc}
   */
  public function getLinkTarget(EntityInterface $entity) : GeneratedUrl {
    assert($entity instanceof ShortcutInterface);
    return $entity->getUrl()
      ->toString(TRUE);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.