class StyleguideLocalTasks in Style Guide 8
Same name and namespace in other branches
- 2.x src/Plugin/Derivative/StyleguideLocalTasks.php \Drupal\styleguide\Plugin\Derivative\StyleguideLocalTasks
Styleguide local tasks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\styleguide\Plugin\Derivative\StyleguideLocalTasks implements ContainerDeriverInterface
Expanded class hierarchy of StyleguideLocalTasks
1 string reference to 'StyleguideLocalTasks'
File
- src/
Plugin/ Derivative/ StyleguideLocalTasks.php, line 14
Namespace
Drupal\styleguide\Plugin\DerivativeView source
class StyleguideLocalTasks extends DeriverBase implements ContainerDeriverInterface {
/**
* The configuration object factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* StyleguideLocalTasks constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The Drupal config factory.
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The Drupal theme habdler.
*/
public function __construct(ConfigFactoryInterface $config_factory, ThemeHandlerInterface $theme_handler) {
$this->configFactory = $config_factory;
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('config.factory'), $container
->get('theme_handler'));
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
StyleguideLocalTasks:: |
protected | property | The configuration object factory. | |
StyleguideLocalTasks:: |
protected | property | The theme handler. | |
StyleguideLocalTasks:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
StyleguideLocalTasks:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
StyleguideLocalTasks:: |
public | function | StyleguideLocalTasks constructor. |