Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Field / Plugin / Field / FieldFormatter / StringFormatter.php
index 95ab0b2cf48e0230e903a156787ef390dd0cebcc..08642a06b90a2f216f8403818fecf43402b1aad2 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemInterface;
@@ -116,8 +117,8 @@ 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 = $items->getEntity()->urlInfo('revision');
+      // For the default revision this falls back to 'canonical'.
+      $url = $this->getEntityUrl($items->getEntity());
     }
 
     foreach ($items as $delta => $item) {
@@ -155,4 +156,18 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
     ];
   }
 
+  /**
+   * Gets the URI elements of the entity.
+   *
+   * @param \Drupal\Core\Entity\EntityInterface $entity
+   *   The entity object.
+   *
+   * @return \Drupal\Core\Url
+   *   The URI elements of the entity.
+   */
+  protected function getEntityUrl(EntityInterface $entity) {
+    // For the default revision this falls back to 'canonical'.
+    return $entity->toUrl('revision');
+  }
+
 }