Mercurial > hg > isophonics-drupal-site
annotate core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\system\Plugin\Derivative; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Component\Plugin\Derivative\DeriverBase; |
Chris@0 | 6 use Drupal\Core\Extension\ThemeHandlerInterface; |
Chris@0 | 7 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; |
Chris@0 | 8 use Symfony\Component\DependencyInjection\ContainerInterface; |
Chris@0 | 9 |
Chris@0 | 10 /** |
Chris@0 | 11 * Provides dynamic tabs based on active themes. |
Chris@0 | 12 */ |
Chris@0 | 13 class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface { |
Chris@0 | 14 |
Chris@0 | 15 /** |
Chris@0 | 16 * The theme handler. |
Chris@0 | 17 * |
Chris@0 | 18 * @var \Drupal\Core\Extension\ThemeHandlerInterface |
Chris@0 | 19 */ |
Chris@0 | 20 protected $themeHandler; |
Chris@0 | 21 |
Chris@0 | 22 /** |
Chris@0 | 23 * Constructs a new ThemeLocalTask instance. |
Chris@0 | 24 * |
Chris@0 | 25 * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler |
Chris@0 | 26 * The theme handler. |
Chris@0 | 27 */ |
Chris@0 | 28 public function __construct(ThemeHandlerInterface $theme_handler) { |
Chris@0 | 29 $this->themeHandler = $theme_handler; |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 /** |
Chris@0 | 33 * {@inheritdoc} |
Chris@0 | 34 */ |
Chris@0 | 35 public static function create(ContainerInterface $container, $base_plugin_id) { |
Chris@0 | 36 return new static( |
Chris@0 | 37 $container->get('theme_handler') |
Chris@0 | 38 ); |
Chris@0 | 39 } |
Chris@0 | 40 |
Chris@0 | 41 /** |
Chris@0 | 42 * {@inheritdoc} |
Chris@0 | 43 */ |
Chris@0 | 44 public function getDerivativeDefinitions($base_plugin_definition) { |
Chris@0 | 45 foreach ($this->themeHandler->listInfo() as $theme_name => $theme) { |
Chris@0 | 46 if ($this->themeHandler->hasUi($theme_name)) { |
Chris@0 | 47 $this->derivatives[$theme_name] = $base_plugin_definition; |
Chris@0 | 48 $this->derivatives[$theme_name]['title'] = $theme->info['name']; |
Chris@0 | 49 $this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name]; |
Chris@0 | 50 } |
Chris@0 | 51 } |
Chris@0 | 52 return $this->derivatives; |
Chris@0 | 53 } |
Chris@0 | 54 |
Chris@0 | 55 } |