You are here

public function ThemeLocalTask::getDerivativeDefinitions in Drupal 10

Same name in this branch
  1. 10 core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php \Drupal\block\Plugin\Derivative\ThemeLocalTask::getDerivativeDefinitions()
  2. 10 core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php \Drupal\system\Plugin\Derivative\ThemeLocalTask::getDerivativeDefinitions()
Same name and namespace in other branches
  1. 8 core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php \Drupal\block\Plugin\Derivative\ThemeLocalTask::getDerivativeDefinitions()
  2. 9 core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php \Drupal\block\Plugin\Derivative\ThemeLocalTask::getDerivativeDefinitions()

File

core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php, line 44

Class

ThemeLocalTask
Provides dynamic tabs based on active themes.

Namespace

Drupal\block\Plugin\Derivative

Code

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;
      unset($this->derivatives[$theme_name]['route_parameters']);
    }
  }
  return $this->derivatives;
}