Skip to content
Snippets Groups Projects
Commit ef01ed23 authored by Alex Pott's avatar Alex Pott
Browse files

Revert "Issue #2745911 by tim.plunkett, pwolanin: Block add links should respect destination"

parent 17c15fb6
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment