From e74151deece8942bdcbde8cbad9eda345765d2df Mon Sep 17 00:00:00 2001
From: beram <beram@smile.fr>
Date: Tue, 20 Jun 2017 00:44:11 +0200
Subject: Issue #2732065: Flag links redirect to the system path rather than
 the actual path the user was on.

---
 src/ActionLink/ActionLinkTypeBase.php | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/ActionLink/ActionLinkTypeBase.php b/src/ActionLink/ActionLinkTypeBase.php
index 2cd9ef2..905d93f 100644
--- a/src/ActionLink/ActionLinkTypeBase.php
+++ b/src/ActionLink/ActionLinkTypeBase.php
@@ -5,6 +5,7 @@ namespace Drupal\flag\ActionLink;
 use Drupal\Component\Plugin\PluginBase;
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Link;
+use Drupal\Core\Routing\RedirectDestinationTrait;
 use Drupal\Core\Url;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Cache\CacheableMetadata;
@@ -32,6 +33,7 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
   protected $currentUser;
 
   use StringTranslationTrait;
+  use RedirectDestinationTrait;
 
   /**
    * Build a new link type instance and sets the configuration.
@@ -152,14 +154,7 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
    *  A string containing a destination URL parameter.
    */
   protected function getDestination() {
-    $current_url = Url::fromRoute('<current>');
-    $route_params = $current_url->getRouteParameters();
-
-    if (isset($route_params['destination'])) {
-      return $route_params['destination'];
-    }
-
-    return $current_url->getInternalPath();
+    return $this->getRedirectDestination()->get();
   }
 
   /**
-- 
1.9.1

