Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / src / Command / Theme / PathCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Theme\PathCommand.
6  */
7
8 namespace Drupal\Console\Command\Theme;
9
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 Symfony\Component\Console\Command\Command;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Extension\Manager;
17 use Drupal\Console\Command\Shared\ModuleTrait;
18 use Drupal\Console\Core\Style\DrupalStyle;
19
20 class PathCommand extends Command
21 {
22     use CommandTrait;
23     use ModuleTrait;
24
25     /**
26      * @var Manager
27      */
28     protected $extensionManager;
29
30     /**
31      * PathCommand constructor.
32      *
33      * @param Manager $extensionManager
34      */
35     public function __construct(Manager $extensionManager)
36     {
37         $this->extensionManager = $extensionManager;
38         parent::__construct();
39     }
40
41     protected function configure()
42     {
43         $this
44             ->setName('theme:path')
45             ->setDescription($this->trans('commands.theme.path.description'))
46             ->addArgument(
47                 'theme',
48                 InputArgument::REQUIRED,
49                 $this->trans('commands.theme.path.arguments.module')
50             )
51             ->addOption(
52                 'absolute',
53                 null,
54                 InputOption::VALUE_NONE,
55                 $this->trans('commands.theme.path.options.absolute')
56             );
57     }
58
59     protected function execute(InputInterface $input, OutputInterface $output)
60     {
61         $io = new DrupalStyle($input, $output);
62
63         $theme = $input->getArgument('theme');
64
65         $fullPath = $input->getOption('absolute');
66
67         $theme = $this->extensionManager->getTheme($theme);
68
69         $io->info(
70             $theme->getPath($fullPath)
71         );
72     }
73
74     /**
75      * {@inheritdoc}
76      */
77     protected function interact(InputInterface $input, OutputInterface $output)
78     {
79         $io = new DrupalStyle($input, $output);
80
81         // --module argument
82         $theme = $input->getArgument('theme');
83         if (!$theme) {
84             // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
85             $module = $this->moduleQuestion($io);
86             $input->setArgument('theme', $module);
87         }
88     }
89 }