class StyleguideMenuLinks in Style Guide 8
Same name and namespace in other branches
- 2.x src/Plugin/Derivative/StyleguideMenuLinks.php \Drupal\styleguide\Plugin\Derivative\StyleguideMenuLinks
Styleguide menu links.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\styleguide\Plugin\Derivative\StyleguideMenuLinks implements ContainerDeriverInterface
Expanded class hierarchy of StyleguideMenuLinks
1 string reference to 'StyleguideMenuLinks'
File
- src/
Plugin/ Derivative/ StyleguideMenuLinks.php, line 13
Namespace
Drupal\styleguide\Plugin\DerivativeView source
class StyleguideMenuLinks extends DeriverBase implements ContainerDeriverInterface {
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* StyleguideMenuLinks constructor.
*
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The Drupal theme habdler.
*/
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('theme_handler'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$themes = $this->themeHandler
->rebuildThemeData();
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,
];
}
}
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:: |
|
StyleguideMenuLinks:: |
protected | property | The theme handler. | |
StyleguideMenuLinks:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
StyleguideMenuLinks:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
StyleguideMenuLinks:: |
public | function | StyleguideMenuLinks constructor. |