hasUi example

$container->get('theme_handler')
    );
  }

  /** * {@inheritdoc} */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $default_theme = $this->themeHandler->getDefault();

    foreach ($this->themeHandler->listInfo() as $theme_name => $theme) {
      if ($this->themeHandler->hasUi($theme_name)) {
        $this->derivatives[$theme_name] = $base_plugin_definition;
        $this->derivatives[$theme_name]['title'] = $theme->info['name'];
        $this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name];
      }
      // Default task!       if ($default_theme == $theme_name) {
        $this->derivatives[$theme_name]['route_name'] = $base_plugin_definition['parent_id'];
        // Emulate default logic because without the base plugin id we can't         // change the base_route.         $this->derivatives[$theme_name]['weight'] = -10;

        
public static function create(ContainerInterface $container$base_plugin_id) {
    return new static(
      $container->get('theme_handler')
    );
  }

  /** * {@inheritdoc} */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->themeHandler->listInfo() as $theme_name => $theme) {
      if ($this->themeHandler->hasUi($theme_name)) {
        $this->derivatives[$theme_name] = $base_plugin_definition;
        $this->derivatives[$theme_name]['title'] = $theme->info['name'];
        $this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name];
      }
    }
    return $this->derivatives;
  }

}

  public function listing($theme = NULL, Request $request = NULL) {
    $theme = $theme ?: $this->config('system.theme')->get('default');
    if (!$this->themeHandler->hasUi($theme)) {
      throw new NotFoundHttpException();
    }

    return $this->entityTypeManager()->getListBuilder('block')->render($theme$request);
  }

}

  public function buildForm(array $form, FormStateInterface $form_state$theme = '') {
    $form = parent::buildForm($form$form_state);

    $themes = $this->themeHandler->listInfo();

    // Default settings are defined in theme_get_setting() in includes/theme.inc     if ($theme) {
      if (!$this->themeHandler->hasUi($theme)) {
        throw new NotFoundHttpException();
      }
      $var = 'theme_' . $theme . '_settings';
      $config_key = $theme . '.settings';
      $themes = $this->themeHandler->listInfo();
      $features = $themes[$theme]->info['features'];
    }
    else {
      $var = 'theme_settings';
      $config_key = 'system.theme.global';
    }
    
/** * Returns a block theme demo page. * * @param string $theme * The name of the theme. * * @return array * A #type 'page' render array containing the block region demo. */
  public function demo($theme) {
    if (!$this->themeHandler->hasUi($theme)) {
      throw new NotFoundHttpException();
    }

    $page = [
      '#title' => Html::escape($this->themeHandler->getName($theme)),
      '#type' => 'page',
      '#attached' => [
        'drupalSettings' => [
          // The block demonstration page is not marked as an administrative           // page by \Drupal::service('router.admin_context')->isAdminRoute()           // function in order to use the frontend theme. Since JavaScript
Home | Imprint | This part of the site doesn't use cookies.