You are here

public function ThemeLocalTask::getDerivativeDefinitions in Skinr 8.2

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

skinr_ui/src/Plugin/Derivative/ThemeLocalTask.php, line 61
Contains \Drupal\skinr_ui\Plugin\Derivative\ThemeLocalTask.

Class

ThemeLocalTask
Provides dynamic tabs based on active themes.

Namespace

Drupal\skinr_ui\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $default_theme = $this->config
    ->get('default');
  foreach ($this->themeHandler
    ->listInfo() as $theme_name => $theme) {
    if ($theme->status) {
      $this->derivatives[$theme_name] = $base_plugin_definition;
      $this->derivatives[$theme_name]['title'] = $theme->info['name'];
      $this->derivatives[$theme_name]['route_parameters'] = array(
        'theme' => $theme_name,
      );
    }

    // Default task!
    if ($default_theme == $theme_name) {
      $this->derivatives[$theme_name]['route_name'] = 'skinr_ui.library';

      // 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;
}