diff -u b/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php --- b/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 @@ protected $themeManager; /** + * The theme handler. + * + * @var \Drupal\Core\Extension\ThemeHandlerInterface + */ + protected $themeHandler; + + /** * The form builder. * * @var \Drupal\Core\Form\FormBuilderInterface @@ -81,14 +89,17 @@ * 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 @@ $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 @@ $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(); @@ -166,14 +186,6 @@ '#type' => 'value', '#value' => $this->theme, ); - - $theme_info = \Drupal::service('theme_handler')->getTheme($this->theme); - $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)), - ); - $form['blocks'] = array( '#type' => 'table', '#header' => array( diff -u b/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig --- b/core/modules/block/templates/block-list.html.twig +++ b/core/modules/block/templates/block-list.html.twig @@ -14,7 +14,7 @@ */ #}