public function StyleguideLocalTasks::getDerivativeDefinitions in Style Guide 8
Same name and namespace in other branches
- 2.x src/Plugin/Derivative/StyleguideLocalTasks.php \Drupal\styleguide\Plugin\Derivative\StyleguideLocalTasks::getDerivativeDefinitions()
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
- src/
Plugin/ Derivative/ StyleguideLocalTasks.php, line 56
Class
- StyleguideLocalTasks
- Styleguide local tasks.
Namespace
Drupal\styleguide\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$default_theme = $this->configFactory
->get('system.theme')
->get('default');
$themes = $this->themeHandler
->rebuildThemeData();
$weight = 0;
foreach ($themes as &$theme) {
if (!empty($theme->info['hidden'])) {
continue;
}
if ($theme->status) {
$route_name = 'styleguide.' . $theme
->getName();
$this->derivatives[$route_name] = $base_plugin_definition + [
'title' => $theme->info['name'],
'route_name' => $route_name,
'parent_id' => 'styleguide.page',
'weight' => $weight++,
];
if ($default_theme == $theme
->getName()) {
$this->derivatives[$route_name]['route_name'] = 'styleguide.page';
}
}
}
return $this->derivatives;
}