diff --git a/core/lib/Drupal/Core/Form/FormBase.php b/core/lib/Drupal/Core/Form/FormBase.php index d7c2bfd..5c2d2af 100644 --- a/core/lib/Drupal/Core/Form/FormBase.php +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -11,6 +11,7 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Routing\LinkGeneratorTrait; +use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Routing\UrlGeneratorTrait; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -22,9 +23,11 @@ * @ingroup form_api */ abstract class FormBase implements FormInterface, ContainerInjectionInterface { - use StringTranslationTrait; + use DependencySerializationTrait; use LinkGeneratorTrait; + use RedirectDestinationTrait; + use StringTranslationTrait; use UrlGeneratorTrait; /** diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php index c6714be..73ad3c42 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Render\Element; +use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\Html as HtmlUtility; @@ -17,6 +18,8 @@ */ class Link extends RenderElement { + use RedirectDestinationTrait; + /** * {@inheritdoc} */ diff --git a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php index 7d0adb7..6b16e0a 100644 --- a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php +++ b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php @@ -63,7 +63,7 @@ public static function preRenderCompactLink($element) { $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'off')); $element['#options'] = array( 'attributes' => array('title' => t('Expand layout to include descriptions.')), - 'query' => \Drupal::service('redirect.destination')->getAsArray(), + 'query' => $this->getDestination(), ); } else { @@ -71,7 +71,7 @@ public static function preRenderCompactLink($element) { $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'on')); $element['#options'] = array( 'attributes' => array('title' => t('Compress layout by hiding descriptions.')), - 'query' => \Drupal::service('redirect.destination')->getAsArray(), + 'query' => $this->getDestination(), ); } diff --git a/core/modules/book/src/Form/BookAdminEditForm.php b/core/modules/book/src/Form/BookAdminEditForm.php index 59c8f18..f49d4a4 100644 --- a/core/modules/book/src/Form/BookAdminEditForm.php +++ b/core/modules/book/src/Form/BookAdminEditForm.php @@ -13,8 +13,8 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\Core\Render\Element; +use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Url; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -24,6 +24,8 @@ */ class BookAdminEditForm extends FormBase { + use RedirectDestinationTrait; + /** * The node storage. * @@ -39,26 +41,16 @@ class BookAdminEditForm extends FormBase { protected $bookManager; /** - * The redirect destination service. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - - /** * Constructs a new BookAdminEditForm. * * @param \Drupal\Core\Entity\EntityStorageInterface $node_storage * The custom block storage. * @param \Drupal\book\BookManagerInterface $book_manager * The book manager. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination service. */ - public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, RedirectDestinationInterface $redirect_destination) { + public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager) { $this->nodeStorage = $node_storage; $this->bookManager = $book_manager; - $this->redirectDestination = $redirect_destination; } /** @@ -68,8 +60,7 @@ public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( $entity_manager->getStorage('node'), - $container->get('book.manager'), - $container->get('redirect.destination') + $container->get('book.manager') ); } @@ -218,7 +209,7 @@ protected function bookAdminTableTree(array $tree, array &$form) { $delta = ($count < 30) ? 15 : intval($count / 2) + 1; $access = \Drupal::currentUser()->hasPermission('administer nodes'); - $destination = $this->redirectDestination->getAsArray(); + $destination = $this->getDestination(); foreach ($tree as $data) { $nid = $data['link']['nid']; diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index 7da32bc..e70c49e 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -160,7 +160,7 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) { } if ($this->authenticatedCanPostComments) { - // We cannot use the direct.destination service here because these links + // We cannot use the redirect.destination service here because these links // sometimes appear on /node and taxonomy listing pages. if ($entity->get($field_name)->getFieldDefinition()->getSetting('form_location') == CommentItemInterface::FORM_SEPARATE_PAGE) { $comment_reply_parameters = [ diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index 8ef2fcb..e8b726e 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -15,7 +15,6 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -53,13 +52,6 @@ class CommentAdminOverview extends FormBase { protected $moduleHandler; /** - * The redirect destination service. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - - /** * Creates a CommentAdminOverview form. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -70,15 +62,12 @@ class CommentAdminOverview extends FormBase { * The date formatter service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination service. */ - public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, DateFormatter $date_formatter, ModuleHandlerInterface $module_handler, RedirectDestinationInterface $redirect_destination) { + public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, DateFormatter $date_formatter, ModuleHandlerInterface $module_handler) { $this->entityManager = $entity_manager; $this->commentStorage = $comment_storage; $this->dateFormatter = $date_formatter; $this->moduleHandler = $module_handler; - $this->redirectDestination = $redirect_destination; } /** @@ -89,8 +78,7 @@ public static function create(ContainerInterface $container) { $container->get('entity.manager'), $container->get('entity.manager')->getStorage('comment'), $container->get('date.formatter'), - $container->get('module_handler'), - $container->get('redirect.destination') + $container->get('module_handler') ); } @@ -179,7 +167,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' // Build a table listing the appropriate comments. $options = array(); - $destination = $this->redirectDestination->getAsArray(); + $destination = $this->getDestination(); $commented_entity_ids = array(); $commented_entities = array(); diff --git a/core/modules/comment/src/Plugin/views/field/Link.php b/core/modules/comment/src/Plugin/views/field/Link.php index 70c5c0e..c2fc23d 100644 --- a/core/modules/comment/src/Plugin/views/field/Link.php +++ b/core/modules/comment/src/Plugin/views/field/Link.php @@ -11,6 +11,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Url; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -24,6 +25,8 @@ */ class Link extends FieldPluginBase { + use RedirectDestinationTrait; + /** * Entity Manager service. * diff --git a/core/modules/comment/src/Plugin/views/field/LinkApprove.php b/core/modules/comment/src/Plugin/views/field/LinkApprove.php index 4311be2..bd8a4be 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkApprove.php +++ b/core/modules/comment/src/Plugin/views/field/LinkApprove.php @@ -9,7 +9,6 @@ use Drupal\comment\CommentInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Url; use Drupal\views\ResultRow; @@ -22,8 +21,6 @@ */ class LinkApprove extends Link { - use RedirectDestinationTrait; - /** * {@inheritdoc} */ diff --git a/core/modules/comment/src/Plugin/views/field/LinkDelete.php b/core/modules/comment/src/Plugin/views/field/LinkDelete.php index 17d670b..88809bb 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkDelete.php +++ b/core/modules/comment/src/Plugin/views/field/LinkDelete.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Plugin\views\field; -use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Session\AccountInterface; use Drupal\views\ResultRow; @@ -20,7 +19,6 @@ */ class LinkDelete extends Link { - use RedirectDestinationTrait; /** * {@inheritdoc} diff --git a/core/modules/comment/src/Plugin/views/field/LinkEdit.php b/core/modules/comment/src/Plugin/views/field/LinkEdit.php index 52347b3..d4d6b1c 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkEdit.php +++ b/core/modules/comment/src/Plugin/views/field/LinkEdit.php @@ -8,7 +8,6 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\views\ResultRow; /** @@ -20,7 +19,6 @@ */ class LinkEdit extends Link { - use RedirectDestinationTrait; protected function defineOptions() { $options = parent::defineOptions(); diff --git a/core/modules/field_ui/src/Form/FieldEditForm.php b/core/modules/field_ui/src/Form/FieldEditForm.php index dbc1646..bfcff1f 100644 --- a/core/modules/field_ui/src/Form/FieldEditForm.php +++ b/core/modules/field_ui/src/Form/FieldEditForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Form\FormBase; use Drupal\Component\Utility\String; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\field\FieldConfigInterface; use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -39,23 +38,13 @@ class FieldEditForm extends FormBase { protected $entityManager; /** - * The redirect destination service. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - - /** * Constructs a new field form. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination service. */ - public function __construct(EntityManagerInterface $entity_manager, RedirectDestinationInterface $redirect_destination) { + public function __construct(EntityManagerInterface $entity_manager) { $this->entityManager = $entity_manager; - $this->redirectDestination = $redirect_destination; } /** @@ -63,8 +52,7 @@ public function __construct(EntityManagerInterface $entity_manager, RedirectDest */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), - $container->get('redirect.destination') + $container->get('entity.manager') ); } @@ -231,7 +219,7 @@ public function delete(array &$form, FormStateInterface $form_state) { $destination = array(); $request = $this->getRequest(); if ($request->query->has('destination')) { - $destination = $this->redirectDestination->getAsArray(); + $destination = $this->getDestination(); $request->query->remove('destination'); } $entity_type = $this->entityManager->getDefinition($this->field->entity_type); diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index 0df04d9..b1d9a2d 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -13,7 +13,6 @@ use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\FieldStorageConfigInterface; use Drupal\field_ui\FieldUI; @@ -67,13 +66,6 @@ class FieldStorageAddForm extends FormBase { protected $configFactory; /** - * The redirect destination service. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - - /** * Constructs a new FieldStorageAddForm object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -84,15 +76,12 @@ class FieldStorageAddForm extends FormBase { * The configuration factory. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination service. */ - public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_plugin_manager, QueryFactory $query_factory, ConfigFactoryInterface $config_factory, RedirectDestinationInterface $redirect_destination) { + public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_plugin_manager, QueryFactory $query_factory, ConfigFactoryInterface $config_factory) { $this->entityManager = $entity_manager; $this->fieldTypePluginManager = $field_type_plugin_manager; $this->queryFactory = $query_factory; $this->configFactory = $config_factory; - $this->redirectDestination = $redirect_destination; } /** @@ -110,8 +99,7 @@ public static function create(ContainerInterface $container) { $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'), $container->get('entity.query'), - $container->get('config.factory'), - $container->get('redirect.destination') + $container->get('config.factory') ); } @@ -394,7 +382,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } if ($destinations) { - $destination = $this->redirectDestination->getAsArray(); + $destination = $this->getDestination(); $destinations[] = $destination['destination']; $form_state->setRedirectUrl(FieldUI::getNextDestination($destinations, $form_state)); } diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php index 87c195d..24f5142 100644 --- a/core/modules/forum/src/Form/Overview.php +++ b/core/modules/forum/src/Form/Overview.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\Core\Url; use Drupal\taxonomy\Form\OverviewTerms; use Drupal\Core\Config\ConfigFactoryInterface; @@ -37,11 +36,9 @@ class Overview extends OverviewTerms { * 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, RedirectDestinationInterface $redirect_destination) { - parent::__construct($module_handler, $entity_manager, $redirect_destination); + public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) { + parent::__construct($module_handler, $entity_manager); $this->entityManager = $entity_manager; } diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php index d467316..91cd8f0 100644 --- a/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -17,7 +17,6 @@ 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; @@ -57,13 +56,6 @@ class MenuForm extends EntityForm { protected $linkGenerator; /** - * The redirect destination service. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - - /** * The overview tree form. * * @var array @@ -81,15 +73,12 @@ 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, RedirectDestinationInterface $redirect_destination) { + public function __construct(QueryFactory $entity_query_factory, MenuLinkManagerInterface $menu_link_manager, MenuLinkTreeInterface $menu_tree, LinkGeneratorInterface $link_generator) { $this->entityQueryFactory = $entity_query_factory; $this->menuLinkManager = $menu_link_manager; $this->menuTree = $menu_tree; $this->linkGenerator = $link_generator; - $this->redirectDestination = $redirect_destination; } /** @@ -100,8 +89,7 @@ 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('redirect.destination') + $container->get('link_generator') ); } @@ -395,7 +383,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'] = $this->redirectDestination->getAsArray(); + $operations['edit']['query'] = $this->getDestination(); } else { // Fall back to the standard edit link. @@ -412,7 +400,7 @@ protected function buildOverviewTreeForm($tree, $delta) { } elseif ($delete_link = $link->getDeleteRoute()) { $operations['delete']['url'] = $delete_link; - $operations['delete']['query'] = $this->redirectDestination->getAsArray(); + $operations['delete']['query'] = $this->getDestination(); $operations['delete']['title'] = $this->t('Delete'); } if ($link->isTranslatable()) { diff --git a/core/modules/path/src/Form/EditForm.php b/core/modules/path/src/Form/EditForm.php index 801889c..896aa77 100644 --- a/core/modules/path/src/Form/EditForm.php +++ b/core/modules/path/src/Form/EditForm.php @@ -58,7 +58,7 @@ public function deleteSubmit(array &$form, FormStateInterface $form_state) { )); if ($this->getRequest()->query->has('destination')) { - $url->setOption('query', \Drupal::service('redirect.destination')->getAsArray()); + $url->setOption('query', $this->getDestination()); $this->getRequest()->query->remove('destination'); } diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index d857401..964b2bd 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -26,6 +26,7 @@ class BulkForm extends FieldPluginBase { use RedirectDestinationTrait; + /** * The action storage. * diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php index 9ba9f87..dbb14b1 100644 --- a/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -11,7 +11,6 @@ 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; @@ -35,26 +34,16 @@ 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, RedirectDestinationInterface $redirect_destination) { + public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) { $this->moduleHandler = $module_handler; $this->storageController = $entity_manager->getStorage('taxonomy_term'); - $this->redirectDestination = $redirect_destination; } /** @@ -63,8 +52,7 @@ 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('redirect.destination') + $container->get('entity.manager') ); } @@ -212,7 +200,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Vocabular } $errors = $form_state->getErrors(); - $destination = $this->redirectDestination->getAsArray(); + $destination = $this->getDestination(); $row_position = 0; // Build the actual form. $form['terms'] = array( diff --git a/core/modules/user/src/Plugin/views/field/Link.php b/core/modules/user/src/Plugin/views/field/Link.php index 21431e9..b55a6a4 100644 --- a/core/modules/user/src/Plugin/views/field/Link.php +++ b/core/modules/user/src/Plugin/views/field/Link.php @@ -8,7 +8,7 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RedirectDestinationInterface; +use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Session\AccountInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -26,41 +26,7 @@ */ class Link extends FieldPluginBase { - /** - * The redirect destination service. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('redirect.destination') - ); - } - - /** - * Constructs a Link field plugin. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination service. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RedirectDestinationInterface $redirect_destination) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->redirectDestination = $redirect_destination; - } + use RedirectDestinationTrait; /** * {@inheritdoc} diff --git a/core/modules/user/src/Plugin/views/field/LinkCancel.php b/core/modules/user/src/Plugin/views/field/LinkCancel.php index 489ac58..1d307d4 100644 --- a/core/modules/user/src/Plugin/views/field/LinkCancel.php +++ b/core/modules/user/src/Plugin/views/field/LinkCancel.php @@ -7,7 +7,6 @@ namespace Drupal\user\Plugin\views\field; -use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Entity\EntityInterface; use Drupal\views\ResultRow; @@ -20,8 +19,6 @@ */ class LinkCancel extends Link { - use RedirectDestinationTrait; - /** * {@inheritdoc} */ diff --git a/core/modules/user/src/Plugin/views/field/LinkEdit.php b/core/modules/user/src/Plugin/views/field/LinkEdit.php index dd3b4cd..2683a3e 100644 --- a/core/modules/user/src/Plugin/views/field/LinkEdit.php +++ b/core/modules/user/src/Plugin/views/field/LinkEdit.php @@ -8,7 +8,6 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\views\ResultRow; /** @@ -20,8 +19,6 @@ */ class LinkEdit extends Link { - use RedirectDestinationTrait; - /** * {@inheritdoc} */