caec77890510b65093728926c55bc3ca105a71b7
[yaffs-website] / vendor / drupal / console / src / Command / Debug / FeaturesCommand.php
1 <?php
2
3 /**
4 * @file
5 * Contains \Drupal\Console\Command\Debug\FeaturesCommand.
6 */
7
8 namespace Drupal\Console\Command\Debug;
9
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Command\Shared\FeatureTrait;
14 use Drupal\Console\Annotations\DrupalCommand;
15 use Drupal\Console\Core\Command\Command;
16
17 /**
18  * @DrupalCommand(
19  *     extension = "features",
20  *     extensionType = "module"
21  * )
22  */
23
24 class FeaturesCommand extends Command
25 {
26     use FeatureTrait;
27
28     protected function configure()
29     {
30         $this
31             ->setName('debug:features')
32             ->setDescription($this->trans('commands.debug.features.description'))
33             ->addArgument(
34                 'bundle',
35                 InputArgument::OPTIONAL,
36                 $this->trans('commands.debug.features.arguments.bundle')
37             );
38     }
39
40     protected function execute(InputInterface $input, OutputInterface $output)
41     {
42         $bundle= $input->getArgument('bundle');
43
44         $tableHeader = [
45             $this->trans('commands.debug.features.messages.bundle'),
46             $this->trans('commands.debug.features.messages.name'),
47             $this->trans('commands.debug.features.messages.machine-name'),
48             $this->trans('commands.debug.features.messages.status'),
49             $this->trans('commands.debug.features.messages.state'),
50         ];
51
52         $tableRows = [];
53
54         $features = $this->getFeatureList($bundle);
55
56         foreach ($features as $feature) {
57             $tableRows[] = [$feature['bundle_name'],$feature['name'], $feature['machine_name'], $feature['status'],$feature['state']];
58         }
59
60         $this->getIo()->table($tableHeader, $tableRows, 'compact');
61     }
62 }