diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php
index 76dc46c77b..6a0acb30b1 100644
--- a/core/lib/Drupal/Core/Url.php
+++ b/core/lib/Drupal/Core/Url.php
@@ -887,4 +887,27 @@ public function setUnroutedUrlAssembler(UnroutedUrlAssemblerInterface $url_assem
     return $this;
   }
 
+  /**
+   * Sets the destination of the link.
+   *
+   * @param string $path
+   *   The path to set as the destination. If none is provide then set to the
+   *   current path.
+   */
+  public function setDestination($path = NULL) {
+    if (!isset($path)) {
+      $destination = \Drupal::destination()->getAsArray();
+    }
+    else {
+      $destination = ['destination' => $path];
+    }
+    if ($query = $this->getOption('query')) {
+      $query = array_merge($query, $destination);
+    }
+    else {
+      $query = $destination;
+    }
+    $this->setOption('query', $query);
+  }
+
 }
