diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index b0777a5..98e601e 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -336,7 +336,7 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, F
// Provide helpful pointers for administrators.
if (\Drupal::currentUser()->hasPermission('administer content translation') && !$bundle_is_translatable) {
$toggle_url = \Drupal::url('language.content_settings_page', array(), array(
- 'query' => \Drupal::service('redirect.destination')->getAsArray(),
+ 'query' => \Drupal::destination()->getAsArray(),
));
$form['field']['translatable']['#description'] = t('To configure translation for this field, enable language support for this type.', array(
'@language-settings-url' => $toggle_url,
diff --git a/core/modules/forum/src/Controller/ForumController.php b/core/modules/forum/src/Controller/ForumController.php
index 0f1568d..bb4cfc4 100644
--- a/core/modules/forum/src/Controller/ForumController.php
+++ b/core/modules/forum/src/Controller/ForumController.php
@@ -11,6 +11,7 @@
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityAccessControlHandlerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\forum\ForumManagerInterface;
@@ -67,6 +68,13 @@ class ForumController extends ControllerBase {
protected $nodeTypeStorage;
/**
+ * The redirect destination service.
+ *
+ * @var \Drupal\Core\Routing\RedirectDestinationInterface
+ */
+ protected $redirectDestination;
+
+ /**
* Constructs a ForumController object.
*
* @param \Drupal\forum\ForumManagerInterface $forum_manager
@@ -83,8 +91,10 @@ class ForumController extends ControllerBase {
* Array of active fields on the site.
* @param \Drupal\Core\Entity\EntityStorageInterface $node_type_storage
* Node type storage handler.
+ * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
+ * The redirect destination service.
*/
- public function __construct(ForumManagerInterface $forum_manager, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user, EntityAccessControlHandlerInterface $node_access, array $field_map, EntityStorageInterface $node_type_storage) {
+ public function __construct(ForumManagerInterface $forum_manager, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user, EntityAccessControlHandlerInterface $node_access, array $field_map, EntityStorageInterface $node_type_storage, RedirectDestinationInterface $redirect_destination) {
$this->forumManager = $forum_manager;
$this->vocabularyStorage = $vocabulary_storage;
$this->termStorage = $term_storage;
@@ -92,6 +102,7 @@ public function __construct(ForumManagerInterface $forum_manager, VocabularyStor
$this->nodeAccess = $node_access;
$this->fieldMap = $field_map;
$this->nodeTypeStorage = $node_type_storage;
+ $this->redirectDestination = $redirect_destination;
}
/**
@@ -107,7 +118,8 @@ public static function create(ContainerInterface $container) {
$container->get('current_user'),
$entity_manager->getAccessControlHandler('node'),
$entity_manager->getFieldMap(),
- $entity_manager->getStorage('node_type')
+ $entity_manager->getStorage('node_type'),
+ $container->get('redirect.destination')
);
}
@@ -278,7 +290,7 @@ protected function buildActionLinks($vid, TermInterface $forum_term = NULL) {
'#theme' => 'menu_local_action',
'#link' => array(
'title' => $this->t('Log in to post new content in the forum.'),
- 'url' => Url::fromRoute('user.login', [], ['query' => $this->getDestination()]),
+ 'url' => Url::fromRoute('user.login', [], ['query' => $this->redirectDestination->getAsArray()]),
),
];
}
@@ -286,11 +298,4 @@ protected function buildActionLinks($vid, TermInterface $forum_term = NULL) {
return $links;
}
- /**
- * Wraps drupal_get_destination().
- */
- protected function getDestination() {
- return \Drupal::service('redirect.destination')->getAsArray();
- }
-
}
diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php
index fe23d3e..d467316 100644
--- a/core/modules/menu_ui/src/MenuForm.php
+++ b/core/modules/menu_ui/src/MenuForm.php
@@ -17,6 +17,7 @@
use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Render\Element;
+use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\Core\Routing\UrlGeneratorTrait;
use Drupal\Core\Url;
use Drupal\Core\Utility\LinkGeneratorInterface;
@@ -56,6 +57,13 @@ class MenuForm extends EntityForm {
protected $linkGenerator;
/**
+ * The redirect destination service.
+ *
+ * @var \Drupal\Core\Routing\RedirectDestinationInterface
+ */
+ protected $redirectDestination;
+
+ /**
* The overview tree form.
*
* @var array
@@ -73,12 +81,15 @@ class MenuForm extends EntityForm {
* The menu tree service.
* @param \Drupal\Core\Utility\LinkGeneratorInterface $link_generator
* The link generator.
+ * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
+ * The redirect destination service.
*/
- public function __construct(QueryFactory $entity_query_factory, MenuLinkManagerInterface $menu_link_manager, MenuLinkTreeInterface $menu_tree, LinkGeneratorInterface $link_generator) {
+ public function __construct(QueryFactory $entity_query_factory, MenuLinkManagerInterface $menu_link_manager, MenuLinkTreeInterface $menu_tree, LinkGeneratorInterface $link_generator, RedirectDestinationInterface $redirect_destination) {
$this->entityQueryFactory = $entity_query_factory;
$this->menuLinkManager = $menu_link_manager;
$this->menuTree = $menu_tree;
$this->linkGenerator = $link_generator;
+ $this->redirectDestination = $redirect_destination;
}
/**
@@ -89,7 +100,8 @@ public static function create(ContainerInterface $container) {
$container->get('entity.query'),
$container->get('plugin.manager.menu.link'),
$container->get('menu.link_tree'),
- $container->get('link_generator')
+ $container->get('link_generator'),
+ $container->get('redirect.destination')
);
}
@@ -383,7 +395,7 @@ protected function buildOverviewTreeForm($tree, $delta) {
if ($edit_route) {
$operations['edit']['url'] = $edit_route;
// Bring the user back to the menu overview.
- $operations['edit']['query'] = \Drupal::service('redirect.destination')->getAsArray();
+ $operations['edit']['query'] = $this->redirectDestination->getAsArray();
}
else {
// Fall back to the standard edit link.
@@ -400,7 +412,7 @@ protected function buildOverviewTreeForm($tree, $delta) {
}
elseif ($delete_link = $link->getDeleteRoute()) {
$operations['delete']['url'] = $delete_link;
- $operations['delete']['query'] = \Drupal::service('redirect.destination')->getAsArray();
+ $operations['delete']['query'] = $this->redirectDestination->getAsArray();
$operations['delete']['title'] = $this->t('Delete');
}
if ($link->isTranslatable()) {
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index ccda635..e05d76e 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -313,7 +313,7 @@ function shortcut_preprocess_page(&$variables) {
'link' => $link,
'name' => $variables['title'],
);
- $query += \Drupal::service('redirect.destination')->getAsArray();
+ $query += \Drupal::destination()->getAsArray();
$shortcut_set = shortcut_current_displayed_set();
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 78b3aa4..57f6085 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -726,7 +726,7 @@ function system_user_login(UserInterface $account) {
$config = \Drupal::config('system.date');
// If the user has a NULL time zone, notify them to set a time zone.
if (!$account->getTimezone() && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
- drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => $account->url('edit-form', array('query' => \Drupal::service('redirect.destination')->getAsArray(), 'fragment' => 'edit-timezone')))));
+ drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => $account->url('edit-form', array('query' => \Drupal::destination()->getAsArray(), 'fragment' => 'edit-timezone')))));
}
}
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 01e0f6f..b8cb1c8 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -290,7 +290,7 @@ function update_storage_clear_submit($form, FormStateInterface $form_state) {
* Returns a warning message when there is no data about available updates.
*/
function _update_no_data() {
- $destination = \Drupal::service('redirect.destination')->getAsArray();
+ $destination = \Drupal::destination()->getAsArray();
return t('No update information available. Run cron or check manually.', array(
'@run_cron' => \Drupal::url('system.run_cron', [], ['query' => $destination]),
'@check_manually' => \Drupal::url('update.manual_status', [], ['query' => $destination]),
@@ -590,7 +590,7 @@ function _update_project_status_sort($a, $b) {
*/
function template_preprocess_update_last_check(&$variables) {
$variables['time'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $variables['last']);
- $variables['link'] = \Drupal::l(t('Check manually'), new Url('update.manual_status', array(), array('query' => \Drupal::service('redirect.destination')->getAsArray())));
+ $variables['link'] = \Drupal::l(t('Check manually'), new Url('update.manual_status', array(), array('query' => \Drupal::destination()->getAsArray())));
}
/**
diff --git a/core/modules/views/src/Plugin/views/field/EntityOperations.php b/core/modules/views/src/Plugin/views/field/EntityOperations.php
index b609e16..4a732a6 100644
--- a/core/modules/views/src/Plugin/views/field/EntityOperations.php
+++ b/core/modules/views/src/Plugin/views/field/EntityOperations.php
@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -29,6 +30,13 @@ class EntityOperations extends FieldPluginBase {
protected $entityManager;
/**
+ * The redirect destination service.
+ *
+ * @var \Drupal\Core\Routing\RedirectDestinationInterface
+ */
+ protected $redirectDestination;
+
+ /**
* Constructor.
*
* @param array $configuration
@@ -39,10 +47,13 @@ class EntityOperations extends FieldPluginBase {
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
+ * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
+ * The redirect destination service.
*/
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $entity_manager) {
+ public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $entity_manager, RedirectDestinationInterface $redirect_destination) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityManager = $entity_manager;
+ $this->redirectDestination = $redirect_destination;
}
/**
@@ -53,7 +64,8 @@ public static function create(ContainerInterface $container, array $configuratio
$configuration,
$plugin_id,
$plugin_definition,
- $container->get('entity.manager')
+ $container->get('entity.manager'),
+ $container->get('redirect.destination')
);
}
@@ -102,7 +114,7 @@ public function render(ResultRow $values) {
if (!isset($operation['query'])) {
$operation['query'] = array();
}
- $operation['query'] += \Drupal::service('redirect.destination')->getAsArray();
+ $operation['query'] += $this->redirectDestination->getAsArray();
}
}
$build = array(
diff --git a/core/modules/views/src/Tests/Plugin/views/field/EntityOperationsUnitTest.php b/core/modules/views/src/Tests/Plugin/views/field/EntityOperationsUnitTest.php
index cb89575..2b6f24e 100644
--- a/core/modules/views/src/Tests/Plugin/views/field/EntityOperationsUnitTest.php
+++ b/core/modules/views/src/Tests/Plugin/views/field/EntityOperationsUnitTest.php
@@ -25,6 +25,13 @@ class EntityOperationsUnitTest extends UnitTestCase {
protected $entityManager;
/**
+ * The mocked redirect.destination service.
+ *
+ * @var \Drupal\Core\Routing\RedirectDestinationInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $redirectDestination;
+
+ /**
* The plugin under test.
*
* @var \Drupal\views\Plugin\views\field\EntityOperations
@@ -38,13 +45,18 @@ class EntityOperationsUnitTest extends UnitTestCase {
*/
public function setUp() {
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
+ $this->redirectDestination = $this->getMock('\Drupal\Core\Routing\RedirectDestinationInterface');
+
+ $this->redirectDestination->expects($this->any())
+ ->method('getAsArray')
+ ->willReturn(['destination' => 'foobar']);
$configuration = array();
$plugin_id = $this->randomMachineName();
$plugin_definition = array(
'title' => $this->randomMachineName(),
);
- $this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager);
+ $this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager, $this->redirectDestination);
$view = $this->getMockBuilder('\Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->getMock();
@@ -108,7 +120,7 @@ public function testRenderWithDestination() {
'#type' => 'operations',
'#links' => $operations
);
- $expected_build['#links']['foo']['query'] = \Drupal::service('redirect.destination')->getAsArray();
+ $expected_build['#links']['foo']['query'] = $this->redirectDestination->getAsArray();
$build = $this->plugin->render($result);
$this->assertSame($expected_build, $build);
}
@@ -156,15 +168,3 @@ public function testRenderWithoutDestination() {
}
}
-
-namespace {
-
-if (!function_exists('drupal_get_destination')) {
- function drupal_get_destination() {
- return array(
- 'destination' => 'foobar',
- );
- }
-}
-
-}