You are here

public function Canonical::getUrl in Linkit 8.5

Get the URL associated with a given entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to get a URL for.

Return value

\Drupal\Core\GeneratedUrl A url to replace.

Overrides SubstitutionInterface::getUrl

File

src/Plugin/Linkit/Substitution/Canonical.php, line 23

Class

Canonical
A substitution plugin for the canonical URL of an entity.

Namespace

Drupal\linkit\Plugin\Linkit\Substitution

Code

public function getUrl(EntityInterface $entity) {
  return $entity
    ->toUrl('canonical')
    ->toString(TRUE);
}