Added Entity and Entity Reference Revisions which got dropped somewhere along the...
[yaffs-website] / web / modules / contrib / entity / src / Revision / RevisionableContentEntityBase.php
diff --git a/web/modules/contrib/entity/src/Revision/RevisionableContentEntityBase.php b/web/modules/contrib/entity/src/Revision/RevisionableContentEntityBase.php
new file mode 100644 (file)
index 0000000..f6dc11c
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+namespace Drupal\entity\Revision;
+
+use Drupal\Core\Entity\RevisionableContentEntityBase as BaseRevisionableContentEntityBase;
+
+/**
+ * Improves the url route handling of core's revisionable content entity base.
+ */
+abstract class RevisionableContentEntityBase extends BaseRevisionableContentEntityBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function urlRouteParameters($rel) {
+    $uri_route_parameters = parent::urlRouteParameters($rel);
+
+    if (strpos($this->getEntityType()->getLinkTemplate($rel), $this->getEntityTypeId() . '_revision') !== FALSE) {
+      $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
+    }
+
+    return $uri_route_parameters;
+  }
+
+}