Chris@0: themeHandler = $theme_handler; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function create(ContainerInterface $container) { Chris@0: return new static( Chris@0: $container->get('theme_handler') Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Calls a method on a block and reloads the listing page. Chris@0: * Chris@0: * @param \Drupal\block\BlockInterface $block Chris@0: * The block being acted upon. Chris@0: * @param string $op Chris@0: * The operation to perform, e.g., 'enable' or 'disable'. Chris@0: * Chris@0: * @return \Symfony\Component\HttpFoundation\RedirectResponse Chris@0: * A redirect back to the listing page. Chris@0: */ Chris@0: public function performOperation(BlockInterface $block, $op) { Chris@0: $block->$op()->save(); Chris@17: $this->messenger()->addStatus($this->t('The block settings have been updated.')); Chris@0: return $this->redirect('block.admin_display'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns a block theme demo page. Chris@0: * Chris@0: * @param string $theme Chris@0: * The name of the theme. Chris@0: * Chris@0: * @return array Chris@0: * A #type 'page' render array containing the block region demo. Chris@0: */ Chris@0: public function demo($theme) { Chris@0: if (!$this->themeHandler->hasUi($theme)) { Chris@0: throw new NotFoundHttpException(); Chris@0: } Chris@0: Chris@0: $page = [ Chris@0: '#title' => Html::escape($this->themeHandler->getName($theme)), Chris@0: '#type' => 'page', Chris@0: '#attached' => [ Chris@0: 'drupalSettings' => [ Chris@0: // The block demonstration page is not marked as an administrative Chris@0: // page by \Drupal::service('router.admin_context')->isAdminRoute() Chris@0: // function in order to use the frontend theme. Since JavaScript Chris@0: // relies on a proper separation of admin pages, it needs to know this Chris@0: // is an actual administrative page. Chris@0: 'path' => ['currentPathIsAdmin' => TRUE], Chris@0: ], Chris@0: 'library' => [ Chris@0: 'block/drupal.block.admin', Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Show descriptions in each visible page region, nothing else. Chris@0: $visible_regions = $this->getVisibleRegionNames($theme); Chris@0: foreach (array_keys($visible_regions) as $region) { Chris@0: $page[$region]['block_description'] = [ Chris@0: '#type' => 'inline_template', Chris@0: '#template' => '