Version 1
[yaffs-website] / web / modules / contrib / devel / src / Plugin / Menu / DestinationMenuLink.php
diff --git a/web/modules/contrib/devel/src/Plugin/Menu/DestinationMenuLink.php b/web/modules/contrib/devel/src/Plugin/Menu/DestinationMenuLink.php
new file mode 100644 (file)
index 0000000..4edf1c3
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\devel\Plugin\Menu;
+
+use Drupal\Core\Menu\MenuLinkDefault;
+use Drupal\Core\Url;
+
+/**
+ * Modifies the menu link to add destination.
+ */
+class DestinationMenuLink extends MenuLinkDefault {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getOptions() {
+    $options = parent::getOptions();
+    // Append the current path as destination to the query string.
+    $options['query']['destination'] = Url::fromRoute('<current>')->toString();
+    return $options;
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * @todo Make cacheable once https://www.drupal.org/node/2582797 lands.
+   */
+  public function getCacheMaxAge() {
+    return 0;
+  }
+
+}