diff --git a/core/modules/block/block.module b/core/modules/block/block.module index fa39d87..2e357ab 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -42,10 +42,7 @@ function block_help($route_name, RouteMatchInterface $route_match) { return $output; } if ($route_name == 'block.admin_display' || $route_name == 'block.admin_display_theme') { - $demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default'); - $themes = \Drupal::service('theme_handler')->listInfo(); $output = '

' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. To add a block to a region, or to configure its specific title and visibility settings, click the block title under Place blocks. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the Save blocks button at the bottom of the page.') . '

'; - $output .= '

' . \Drupal::l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), new Url('block.admin_demo', array('theme' => $demo_theme))) . '

'; return $output; } } diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 32d5581..97ace3b 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -15,6 +15,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Form\FormInterface; use Drupal\Core\Form\FormStateInterface; @@ -59,6 +60,13 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface protected $themeManager; /** + * The theme handler. + * + * @var \Drupal\Core\Extension\ThemeHandlerInterface + */ + protected $themeHandler; + + /** * The form builder. * * @var \Drupal\Core\Form\FormBuilderInterface @@ -81,14 +89,17 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface * The block manager. * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager * The theme manager. + * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler + * The theme manager. * @param \Drupal\Core\Form\FormBuilderInterface $form_builder * The form builder. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, BlockManagerInterface $block_manager, ThemeManagerInterface $theme_manager, FormBuilderInterface $form_builder) { + public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, BlockManagerInterface $block_manager, ThemeManagerInterface $theme_manager, ThemeHandlerInterface $theme_handler, FormBuilderInterface $form_builder) { parent::__construct($entity_type, $storage); $this->blockManager = $block_manager; $this->themeManager = $theme_manager; + $this->themeHandler = $theme_handler; $this->formBuilder = $form_builder; } @@ -101,6 +112,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('plugin.manager.block'), $container->get('theme.manager'), + $container->get('theme_handler'), $container->get('form_builder') ); } @@ -141,6 +153,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#attached']['library'][] = 'block/drupal.block.admin'; $form['#attributes']['class'][] = 'clearfix'; + // Build the demonstrate block regions link. + $theme_info = $this->themeHandler->getTheme($this->getThemeName()); + $form['demonstration_link'] = array( + '#type' => 'link', + '#title' => $this->t('Demonstrate block regions (@theme)', array('@theme' => $theme_info->info['name'])), + '#url' => Url::fromRoute('block.admin_demo', array('theme' => $this->theme)), + ); + // Build the form tree. $form['blocks'] = $this->buildBlocksForm(); $form['place_blocks'] = $this->buildPlaceBlocksForm(); diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index 4dc388f..2afe4c5 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -22,7 +22,7 @@ class BlockUiTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'help'); + public static $modules = array('block', 'block_test'); protected $regions; diff --git a/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig index 854d3ce..2ccacaa 100644 --- a/core/modules/block/templates/block-list.html.twig +++ b/core/modules/block/templates/block-list.html.twig @@ -13,9 +13,12 @@ * @ingroup themeable */ #} +
- {{ form|without('place_blocks') }} + {{ form|without('place_blocks', 'demonstration_link') }}
{{ form.place_blocks }}