ThemeLocalTask.php in Zircon Profile 8
File
core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php
View source
<?php
namespace Drupal\block\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
protected $themeHandler;
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('theme_handler'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
$default_theme = $this->themeHandler
->getDefault();
foreach ($this->themeHandler
->listInfo() as $theme_name => $theme) {
if ($this->themeHandler
->hasUi($theme_name)) {
$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,
);
}
if ($default_theme == $theme_name) {
$this->derivatives[$theme_name]['route_name'] = $base_plugin_definition['parent_id'];
$this->derivatives[$theme_name]['weight'] = -10;
unset($this->derivatives[$theme_name]['route_parameters']);
}
}
return $this->derivatives;
}
}