diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index f673e16..e50b297 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -26,7 +26,9 @@ function template_preprocess_custom_block_add_list(&$variables) { $variables['types'][$type->id] = array(); $query = array(); if (($destination = drupal_get_destination()) && $destination['destination'] !== current_path()) { - // A destination parameter is set other than the current path. + // A destination parameter is set other than the current path so we + // respect that by adding it to the generated links. If the current path + // is returned, we ignore it as we don't want to end up back at block/add. $query = $destination; } $variables['types'][$type->id]['link'] = l($type->label(), 'block/add/' . $type->id(), array('query' => $query)); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index 2144253..d5322e1 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -142,14 +142,18 @@ public function testCustomBlockTypeDeletion() { */ public function testsCustomBlockAddTypes() { $this->drupalLogin($this->adminUser); - // Create a block type programmaticaly. + // Create two block types programmatically. $type = $this->createCustomBlockType('foo'); - // Create a block type programmaticaly. $type = $this->createCustomBlockType('bar'); // Get the default theme. $theme = $this->container->get('config.factory')->get('system.theme')->get('default'); + // Get the custom block storage controller. + $storage_controller = $this->container + ->get('plugin.manager.entity') + ->getStorageController('custom_block'); + // Test that adding a block from the 'place blocks' form sends you to the // block configure form. $this->drupalGet('admin/structure/block/list/' . $theme . '/add'); @@ -157,16 +161,11 @@ public function testsCustomBlockAddTypes() { $this->clickLink('foo'); $edit = array('info' => $this->randomName(8)); $this->drupalPost(NULL, $edit, t('Save')); - $blocks = $this->container - ->get('plugin.manager.entity') - ->getStorageController('custom_block') - ->loadByProperties(array('info' => $edit['info'])); + $blocks = $storage_controller->loadByProperties(array('info' => $edit['info'])); if (!empty($blocks)) { $block = reset($blocks); $destination = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . $theme; - $this->assertEqual($this->getUrl(), url($destination, array( - 'absolute' => TRUE - ))); + $this->assertUrl(url($destination, array('absolute' => TRUE))); } else { $this->fail('Could not load created block.'); @@ -179,14 +178,11 @@ public function testsCustomBlockAddTypes() { $this->clickLink('foo'); $edit = array('info' => $this->randomName(8)); $this->drupalPost(NULL, $edit, t('Save')); - $blocks = $this->container - ->get('plugin.manager.entity') - ->getStorageController('custom_block') - ->loadByProperties(array('info' => $edit['info'])); + $blocks = $storage_controller->loadByProperties(array('info' => $edit['info'])); if (!empty($blocks)) { $block = reset($blocks); $destination = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . $theme; - $this->assertEqual($this->getUrl(), url('admin/structure/custom-blocks', array( + $this->assertUrl(url('admin/structure/custom-blocks', array( 'absolute' => TRUE ))); } @@ -194,4 +190,5 @@ public function testsCustomBlockAddTypes() { $this->fail('Could not load created block.'); } } + }