Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / Field / Plugin / Field / FieldFormatter / StringFormatter.php
index 320005ceef003029eb1fc2b1539f1511b9432404..ef2f43c283e9edf302c369e5e41e70c98ff5c2ef 100644 (file)
@@ -124,7 +124,6 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
     $elements = [];
     $url = NULL;
     if ($this->getSetting('link_to_entity')) {
-      // For the default revision this falls back to 'canonical'.
       $url = $this->getEntityUrl($items->getEntity());
     }
 
@@ -173,8 +172,11 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
    *   The URI elements of the entity.
    */
   protected function getEntityUrl(EntityInterface $entity) {
-    // For the default revision this falls back to 'canonical'.
-    return $entity->toUrl('revision');
+    // 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);
   }
 
 }