diff --git a/core/modules/node/src/NodeListBuilder.php b/core/modules/node/src/NodeListBuilder.php index 7acc1a9..1a026a9 100644 --- a/core/modules/node/src/NodeListBuilder.php +++ b/core/modules/node/src/NodeListBuilder.php @@ -14,6 +14,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\Routing\RedirectDestinationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -31,6 +32,13 @@ class NodeListBuilder extends EntityListBuilder { protected $dateFormatter; /** + * The redirect destination service. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface + */ + protected $redirectDestination; + + /** * Constructs a new NodeListBuilder object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -39,11 +47,14 @@ class NodeListBuilder extends EntityListBuilder { * The entity storage class. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. + * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination + * The redirect destination service. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatter $date_formatter) { + public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatter $date_formatter, RedirectDestinationInterface $redirect_destination) { parent::__construct($entity_type, $storage); $this->dateFormatter = $date_formatter; + $this->redirectDestination = $redirect_destination; } /** @@ -53,7 +64,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), - $container->get('date.formatter') + $container->get('date.formatter'), + $container->get('redirect.destination') ); } @@ -128,7 +140,7 @@ public function buildRow(EntityInterface $entity) { protected function getDefaultOperations(EntityInterface $entity) { $operations = parent::getDefaultOperations($entity); - $destination = \Drupal::service('redirect.destination')->getAsArray(); + $destination = $this->redirectDestination->getAsArray(); foreach ($operations as $key => $operation) { $operations[$key]['query'] = $destination; } diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php index 8a87023..02e2ecc 100644 --- a/core/modules/path/src/Controller/PathController.php +++ b/core/modules/path/src/Controller/PathController.php @@ -11,6 +11,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Path\AliasStorageInterface; use Drupal\Core\Path\AliasManagerInterface; +use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -35,16 +36,26 @@ class PathController extends ControllerBase { protected $aliasManager; /** + * The redirect destination service. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface + */ + protected $redirectDestination; + + /** * Constructs a new PathController. * * @param \Drupal\Core\Path\AliasStorageInterface $alias_storage * The path alias storage. * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager * The path alias manager. + * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination + * The redirect destination service. */ - public function __construct(AliasStorageInterface $alias_storage, AliasManagerInterface $alias_manager) { + public function __construct(AliasStorageInterface $alias_storage, AliasManagerInterface $alias_manager, RedirectDestinationInterface $redirect_destination) { $this->aliasStorage = $alias_storage; $this->aliasManager = $alias_manager; + $this->redirectDestination = $redirect_destination; } /** @@ -53,7 +64,8 @@ public function __construct(AliasStorageInterface $alias_storage, AliasManagerIn public static function create(ContainerInterface $container) { return new static( $container->get('path.alias_storage'), - $container->get('path.alias_manager') + $container->get('path.alias_manager'), + $container->get('redirect.destination') ); } @@ -83,7 +95,7 @@ public function adminOverview(Request $request) { $header[] = $this->t('Operations'); $rows = array(); - $destination = \Drupal::service('redirect.destination')->getAsArray(); + $destination = $this->redirectDestination->getAsArray(); foreach ($this->aliasStorage->getAliasesForAdminListing($header, $keys) as $data) { $row = array(); // @todo Should Path module store leading slashes? See diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index 616b9aa..35d8669 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\style\Table; @@ -39,6 +40,13 @@ class BulkForm extends FieldPluginBase { protected $actions = array(); /** + * The redirect destination service. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface; + */ + protected $redirectDestination; + + /** * Constructs a new BulkForm object. * * @param array $configuration @@ -49,18 +57,21 @@ class BulkForm extends FieldPluginBase { * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityStorageInterface $storage * The action storage. + * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination + * The redirect destination service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $storage) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $storage, RedirectDestinationInterface $redirect_destination) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->actionStorage = $storage; + $this->redirectDestination = $redirect_destination; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager')->getStorage('action')); + return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager')->getStorage('action'), $container->get('redirect.destination')); } /** @@ -284,7 +295,7 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { $operation_definition = $action->getPluginDefinition(); if (!empty($operation_definition['confirm_form_route_name'])) { $options = array( - 'query' => \Drupal::service('redirect.destination')->getAsArray(), + 'query' => $this->redirectDestination->getAsArray(), ); $form_state->setRedirect($operation_definition['confirm_form_route_name'], array(), $options); } diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php index 5fe6343..9ba9f87 100644 --- a/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -11,6 +11,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\taxonomy\VocabularyInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -34,16 +35,26 @@ class OverviewTerms extends FormBase { protected $storageController; /** + * The redirect destination service. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface + */ + protected $redirectDestination; + + /** * Constructs an OverviewTerms object. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. + * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination + * The redirect destination service. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) { + public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager, RedirectDestinationInterface $redirect_destination) { $this->moduleHandler = $module_handler; $this->storageController = $entity_manager->getStorage('taxonomy_term'); + $this->redirectDestination = $redirect_destination; } /** @@ -52,7 +63,8 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityManage public static function create(ContainerInterface $container) { return new static( $container->get('module_handler'), - $container->get('entity.manager') + $container->get('entity.manager'), + $container->get('redirect.destination') ); } @@ -200,7 +212,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Vocabular } $errors = $form_state->getErrors(); - $destination = \Drupal::service('redirect.destination')->getAsArray(); + $destination = $this->redirectDestination->getAsArray(); $row_position = 0; // Build the actual form. $form['terms'] = array( diff --git a/core/modules/user/src/UserListBuilder.php b/core/modules/user/src/UserListBuilder.php index b6d9090..f65643a 100644 --- a/core/modules/user/src/UserListBuilder.php +++ b/core/modules/user/src/UserListBuilder.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Routing\RedirectDestinationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -37,6 +38,13 @@ class UserListBuilder extends EntityListBuilder { protected $dateFormatter; /** + * The redirect destination service. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface + */ + protected $redirectDestination; + + /** * Constructs a new UserListBuilder object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -47,11 +55,14 @@ class UserListBuilder extends EntityListBuilder { * The entity query factory. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. + * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination + * The redirect destination service. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, QueryFactory $query_factory, DateFormatter $date_formatter) { + public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, QueryFactory $query_factory, DateFormatter $date_formatter, RedirectDestinationInterface $redirect_destination) { parent::__construct($entity_type, $storage); $this->queryFactory = $query_factory; $this->dateFormatter = $date_formatter; + $this->redirectDestination = $redirect_destination; } /** @@ -152,7 +163,7 @@ public function buildRow(EntityInterface $entity) { public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); if (isset($operations['edit'])) { - $destination = \Drupal::service('redirect.destination')->getAsArray(); + $destination = $this->redirectDestination->getAsArray(); $operations['edit']['query'] = $destination; } return $operations;