From ef01ed2393480fd0e9cddd9721fed71baea8e00c Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 26 Oct 2016 23:09:02 -0700 Subject: [PATCH] Revert "Issue #2745911 by tim.plunkett, pwolanin: Block add links should respect destination" --- .../src/Controller/BlockLibraryController.php | 20 +-------- core/modules/block/src/Tests/BlockTest.php | 43 ------------------- 2 files changed, 2 insertions(+), 61 deletions(-) diff --git a/core/modules/block/src/Controller/BlockLibraryController.php b/core/modules/block/src/Controller/BlockLibraryController.php index 57862fcc6eaf..79d6eff8cd02 100644 --- a/core/modules/block/src/Controller/BlockLibraryController.php +++ b/core/modules/block/src/Controller/BlockLibraryController.php @@ -8,7 +8,6 @@ use Drupal\Core\EventSubscriber\MainContentViewSubscriber; use Drupal\Core\Menu\LocalActionManagerInterface; use Drupal\Core\Plugin\Context\LazyContextRepository; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -47,13 +46,6 @@ class BlockLibraryController extends ControllerBase { */ protected $localActionManager; - /** - * The redirect destination. - * - * @var \Drupal\Core\Routing\RedirectDestinationInterface - */ - protected $redirectDestination; - /** * Constructs a BlockLibraryController object. * @@ -65,15 +57,12 @@ class BlockLibraryController extends ControllerBase { * The current route match. * @param \Drupal\Core\Menu\LocalActionManagerInterface $local_action_manager * The local action manager. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination. */ - public function __construct(BlockManagerInterface $block_manager, LazyContextRepository $context_repository, RouteMatchInterface $route_match, LocalActionManagerInterface $local_action_manager, RedirectDestinationInterface $redirect_destination) { + public function __construct(BlockManagerInterface $block_manager, LazyContextRepository $context_repository, RouteMatchInterface $route_match, LocalActionManagerInterface $local_action_manager) { $this->blockManager = $block_manager; $this->routeMatch = $route_match; $this->localActionManager = $local_action_manager; $this->contextRepository = $context_repository; - $this->redirectDestination = $redirect_destination; } /** @@ -84,8 +73,7 @@ public static function create(ContainerInterface $container) { $container->get('plugin.manager.block'), $container->get('context.repository'), $container->get('current_route_match'), - $container->get('plugin.manager.menu.local_action'), - $container->get('redirect.destination') + $container->get('plugin.manager.menu.local_action') ); } @@ -148,10 +136,6 @@ public function listBlocks(Request $request, $theme) { if (isset($weight)) { $links['add']['query']['weight'] = $weight; } - $destination = $this->redirectDestination->get(); - if ($destination) { - $links['add']['query']['destination'] = $destination; - } $row['operations']['data'] = [ '#type' => 'operations', '#links' => $links, diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index b13a912f78ef..9fd869a92c59 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -128,49 +128,6 @@ function testBlockVisibilityListedEmpty() { $this->assertNoText($title, 'Block was not displayed to anonymous users on the front page.'); } - /** - * Tests adding a block from the library page with a destination query string. - */ - public function testAddBlockFromLibrary() { - $default_theme = $this->config('system.theme')->get('default'); - $help_url = Url::fromRoute('help.page', ['name' => 'block']); - // Set up the request so we land on the block help page after creation. - $options = [ - 'query' => [ - 'region' => 'sidebar_first', - 'destination' => $help_url->toString(), - ], - ]; - $this->drupalGet(Url::fromRoute('block.admin_library', ['theme' => $default_theme], $options)); - - $block_name = 'system_powered_by_block'; - $add_url = Url::fromRoute('block.admin_add', ['plugin_id' => $block_name, 'theme' => $default_theme]); - $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $add_url->toString()]); - $this->assertEqual(1, count($links), 'Found one matching link'); - - list($path, $query_string) = explode('?', $links[0]['href'], 2); - parse_str($query_string, $query_parts); - $this->assertEqual(t('Place block'), (string) $links[0]); - $this->assertEqual($help_url->toString(), $query_parts['destination'], 'Expected destination query string is in href'); - - // Create a random title for the block. - $title = $this->randomMachineName(8); - $block_id = strtolower($this->randomMachineName(8)); - $edit = [ - 'id' => $block_id, - 'settings[label]' => $title, - ]; - // Create the block using the link parsed from the library page. - $this->drupalPostForm($this->getAbsoluteUrl($links[0]['href']), $edit, t('Save block')); - // Verify that we are redirected according to the original request. - $this->assertUrl($help_url); - - // Ensure that the block was created. - /** @var \Drupal\block\BlockInterface $block */ - $block = Block::load($block_id); - $this->assertEqual($title, $block->label(), 'Found the block with expected title.'); - } - /** * Tests adding a block from the library page with a weight query string. */ -- GitLab