class ThemeLocalTask in Skinr 8.2
Provides dynamic tabs based on active themes.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\skinr_ui\Plugin\Derivative\ThemeLocalTask implements ContainerDeriverInterface
Expanded class hierarchy of ThemeLocalTask
1 string reference to 'ThemeLocalTask'
- skinr_ui.links.task.yml in skinr_ui/
skinr_ui.links.task.yml - skinr_ui/skinr_ui.links.task.yml
File
- skinr_ui/
src/ Plugin/ Derivative/ ThemeLocalTask.php, line 19 - Contains \Drupal\skinr_ui\Plugin\Derivative\ThemeLocalTask.
Namespace
Drupal\skinr_ui\Plugin\DerivativeView source
class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
/**
* Stores the theme settings config object.
*
* @var \Drupal\Core\Config\Config
*/
protected $config;
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* Constructs a new ThemeLocalTask.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
*/
public function __construct(ConfigFactoryInterface $config_factory, ThemeHandlerInterface $theme_handler) {
$this->config = $config_factory
->get('system.theme');
$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->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;
}
}
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:: |
|
ThemeLocalTask:: |
protected | property | Stores the theme settings config object. | |
ThemeLocalTask:: |
protected | property | The theme handler. | |
ThemeLocalTask:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
ThemeLocalTask:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
ThemeLocalTask:: |
public | function | Constructs a new ThemeLocalTask. |