X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FTheme%2FPathCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FTheme%2FPathCommand.php;h=05501731ebbd6ab57dcf3a7a172bf012e100eb72;hp=68ad53bd7d7ca83174d3f3763e4dd83c8d848231;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Command/Theme/PathCommand.php b/vendor/drupal/console/src/Command/Theme/PathCommand.php index 68ad53bd7..05501731e 100644 --- a/vendor/drupal/console/src/Command/Theme/PathCommand.php +++ b/vendor/drupal/console/src/Command/Theme/PathCommand.php @@ -11,30 +11,32 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Core\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Core\Extension\ThemeHandler; class PathCommand extends Command { - use CommandTrait; - use ModuleTrait; - /** * @var Manager */ protected $extensionManager; + /** + * @var ThemeHandler + */ + protected $themeHandler; + /** * PathCommand constructor. * - * @param Manager $extensionManager + * @param Manager $extensionManager + * @param ThemeHandler $themeHandler */ - public function __construct(Manager $extensionManager) + public function __construct(Manager $extensionManager, ThemeHandler $themeHandler) { $this->extensionManager = $extensionManager; + $this->themeHandler = $themeHandler; parent::__construct(); } @@ -46,27 +48,34 @@ class PathCommand extends Command ->addArgument( 'theme', InputArgument::REQUIRED, - $this->trans('commands.theme.path.arguments.module') + $this->trans('commands.theme.path.arguments.theme') ) ->addOption( 'absolute', null, InputOption::VALUE_NONE, $this->trans('commands.theme.path.options.absolute') - ); + )->setAliases(['thp']); } protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $theme = $input->getArgument('theme'); $fullPath = $input->getOption('absolute'); + if (!in_array($theme, $this->getThemeList())) { + $this->getIo()->error( + sprintf( + $this->trans('commands.theme.path.messages.invalid-theme-name'), + $theme + ) + ); + return; + } $theme = $this->extensionManager->getTheme($theme); - $io->info( + $this->getIo()->info( $theme->getPath($fullPath) ); } @@ -76,14 +85,19 @@ class PathCommand extends Command */ protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - - // --module argument + // --theme argument $theme = $input->getArgument('theme'); if (!$theme) { - // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion - $module = $this->moduleQuestion($io); - $input->setArgument('theme', $module); + $theme = $this->getIo()->choiceNoList( + $this->trans('commands.theme.path.arguments.theme'), + $this->getThemeList() + ); + $input->setArgument('theme', $theme); } } + + protected function getThemeList() + { + return array_keys($this->themeHandler->rebuildThemeData()); + } }