b9760bd1480ca2fcfb2542675b963cb7355a2cd4
[yaffs-website] / vendor / drupal / console / src / Command / Features / ImportCommand.php
1 <?php
2
3 /**
4 * @file
5 * Contains \Drupal\Console\Command\Features\ImportCommand.
6 */
7
8 namespace Drupal\Console\Command\Features;
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 Drupal\Console\Command\Shared\FeatureTrait;
15 use Drupal\Console\Annotations\DrupalCommand;
16 use Drupal\Console\Core\Command\Command;
17
18 /**
19  * @DrupalCommand(
20  *     extension = "features",
21  *     extensionType = "module"
22  * )
23  */
24
25 class ImportCommand extends Command
26 {
27     use FeatureTrait;
28
29     public function __construct()
30     {
31         parent::__construct();
32     }
33
34     protected function configure()
35     {
36         $this
37             ->setName('features:import')
38             ->setDescription($this->trans('commands.features.import.description'))
39             ->addOption(
40                 'bundle',
41                 null,
42                 InputOption::VALUE_OPTIONAL,
43                 $this->trans('commands.features.import.options.bundle')
44             )
45             ->addArgument(
46                 'packages',
47                 InputArgument::IS_ARRAY,
48                 $this->trans('commands.features.import.arguments.packages')
49             )->setAliases(['fei']);
50         ;
51     }
52
53     protected function execute(InputInterface $input, OutputInterface $output)
54     {
55         $packages = $input->getArgument('packages');
56         $bundle = $input->getOption('bundle');
57       
58         if ($bundle) {
59             $packages = $this->getPackagesByBundle($bundle);
60         }
61       
62         $this->getAssigner($bundle);
63         $this->importFeature($packages);
64     }
65
66     /**
67      * {@inheritdoc}
68      */
69     protected function interact(InputInterface $input, OutputInterface $output)
70     {
71         $packages = $input->getArgument('packages');
72         $bundle = $input->getOption('bundle');
73         if (!$packages) {
74             // @see Drupal\Console\Command\Shared\FeatureTrait::packageQuestion
75             $package = $this->packageQuestion($bundle);
76             $input->setArgument('packages', $package);
77         }
78     }
79 }