function StringFormatter::getEntityUrl

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::getEntityUrl()
  2. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::getEntityUrl()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::getEntityUrl()

Gets the URI elements of the entity.

Parameters

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

Return value

\Drupal\Core\Url The URI elements of the entity.

1 call to StringFormatter::getEntityUrl()
StringFormatter::viewElements in core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
1 method overrides StringFormatter::getEntityUrl()
CommentPermalinkFormatter::getEntityUrl in core/modules/comment/src/Plugin/Field/FieldFormatter/CommentPermalinkFormatter.php

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php, line 177

Class

StringFormatter
Plugin implementation of the 'string' formatter.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

protected function getEntityUrl(EntityInterface $entity) {
    // For the default revision, the 'revision' link template falls back to
    // 'canonical'.
    // @see \Drupal\Core\Entity\Entity::toUrl()
    $rel = $entity->getEntityType()
        ->hasLinkTemplate('revision') ? 'revision' : 'canonical';
    return $entity->toUrl($rel);
}

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