diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc deleted file mode 100644 index 86c59a8..0000000 --- a/core/modules/block/block.admin.inc +++ /dev/null @@ -1,27 +0,0 @@ - array( - 'library' => array( - array('block', 'drupal.block.admin'), - ), - ), - ); -} - diff --git a/core/modules/block/block.module b/core/modules/block/block.module index f1112d6..f3975df 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -7,6 +7,7 @@ use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Utility\NestedArray; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** * Denotes that a block is not enabled in any region and should not be shown. @@ -135,7 +136,6 @@ function block_menu() { 'route_name' => "block.admin_display_$key", ); $items["admin/structure/block/demo/$key"] = array( - 'title' => check_plain($theme->info['name']), 'route_name' => 'block.admin_demo', 'type' => MENU_CALLBACK, 'theme callback' => '_block_custom_theme', @@ -150,7 +150,6 @@ function block_menu() { * * Path: * - admin/structure/block/list/% (for each theme) - * - admin/structure/block/demo/% (for each theme) * * @param $theme * Either the name of a theme or a full theme object. @@ -193,9 +192,7 @@ function block_page_build(&$page) { // Fetch a list of regions for the current theme. $all_regions = system_region_list($theme); - - $item = menu_get_item(); - if ($item['path'] != 'admin/structure/block/demo/' . $theme) { + if (\Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME) != 'block.admin_demo') { // Load all region content assigned via blocks. foreach (array_keys($all_regions) as $region) { // Assign blocks to region. diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockController.php b/core/modules/block/lib/Drupal/block/Controller/BlockController.php index c5c3fc3..c735ba0 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockController.php @@ -7,17 +7,34 @@ namespace Drupal\block\Controller; +use Drupal\Component\Utility\String; +use Drupal\Core\Controller\ControllerBase; +use Symfony\Component\HttpFoundation\Request; + /** - * Controller routines for block routes. + * Controller routines for admin block routes. */ -class BlockController { +class BlockController extends ControllerBase { /** - * @todo Remove block_admin_demo(). + * Returns a block theme demo page. + * + * @param string $theme + * The name of the theme. + * + * @return array + * A render array containing the CSS and title for the block region demo. */ public function demo($theme) { - module_load_include('admin.inc', 'block'); - return block_admin_demo($theme); + $themes = list_themes(); + return array( + '#title' => String::checkPlain($themes[$theme]->info['name']), + '#attached' => array( + 'library' => array( + array('block', 'drupal.block.admin'), + ), + ), + ); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php index d996b1e..48c46c3 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php @@ -68,6 +68,17 @@ function setUp() { } /** + * Test block demo page exists and functions correctly. + */ + public function testBlockDemoUiPage() { + $this->drupalPlaceBlock('system_help_block', array('region' => 'help')); + $this->drupalGet('admin/structure/block'); + $this->clickLink(t('Demonstrate block regions (@theme)', array('@theme' => 'Stark'))); + $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', array(':title' => 'Highlighted')); + $this->assertTrue(!empty($elements), 'Block demo regions are shown.'); + } + + /** * Test block admin page exists and functions correctly. */ function testBlockAdminUiPage() {