5 * Contains \Drupal\Console\Command\Theme\PathCommand.
8 namespace Drupal\Console\Command\Theme;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Drupal\Console\Core\Command\Command;
15 use Drupal\Console\Extension\Manager;
16 use Drupal\Core\Extension\ThemeHandler;
18 class PathCommand extends Command
23 protected $extensionManager;
28 protected $themeHandler;
31 * PathCommand constructor.
33 * @param Manager $extensionManager
34 * @param ThemeHandler $themeHandler
36 public function __construct(Manager $extensionManager, ThemeHandler $themeHandler)
38 $this->extensionManager = $extensionManager;
39 $this->themeHandler = $themeHandler;
40 parent::__construct();
43 protected function configure()
46 ->setName('theme:path')
47 ->setDescription($this->trans('commands.theme.path.description'))
50 InputArgument::REQUIRED,
51 $this->trans('commands.theme.path.arguments.theme')
56 InputOption::VALUE_NONE,
57 $this->trans('commands.theme.path.options.absolute')
58 )->setAliases(['thp']);
61 protected function execute(InputInterface $input, OutputInterface $output)
63 $theme = $input->getArgument('theme');
65 $fullPath = $input->getOption('absolute');
67 if (!in_array($theme, $this->getThemeList())) {
68 $this->getIo()->error(
70 $this->trans('commands.theme.path.messages.invalid-theme-name'),
76 $theme = $this->extensionManager->getTheme($theme);
79 $theme->getPath($fullPath)
86 protected function interact(InputInterface $input, OutputInterface $output)
89 $theme = $input->getArgument('theme');
91 $theme = $this->getIo()->choiceNoList(
92 $this->trans('commands.theme.path.arguments.theme'),
95 $input->setArgument('theme', $theme);
99 protected function getThemeList()
101 return array_keys($this->themeHandler->rebuildThemeData());