More tidying.
[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\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Core\Style\DrupalStyle;
17 use Drupal\Console\Annotations\DrupalCommand;
18 use Symfony\Component\Console\Command\Command;
19
20 /**
21  * @DrupalCommand(
22  *     extension = "features",
23  *     extensionType = "module"
24  * )
25  */
26
27 class ImportCommand extends Command
28 {
29     use CommandTrait;
30     use FeatureTrait;
31
32     public function __construct()
33     {
34         parent::__construct();
35     }
36
37     protected function configure()
38     {
39         $this
40             ->setName('features:import')
41             ->setDescription($this->trans('commands.features.import.description'))
42             ->addOption(
43                 'bundle',
44                 null,
45                 InputOption::VALUE_OPTIONAL,
46                 $this->trans('commands.features.import.options.bundle')
47             )
48             ->addArgument(
49                 'packages',
50                 InputArgument::IS_ARRAY,
51                 $this->trans('commands.features.import.arguments.packages')
52             );
53     }
54
55     protected function execute(InputInterface $input, OutputInterface $output)
56     {
57         $io = new DrupalStyle($input, $output);
58
59         $packages = $input->getArgument('packages');
60         $bundle = $input->getOption('bundle');
61       
62         if ($bundle) {
63             $packages = $this->getPackagesByBundle($bundle);
64         }
65       
66         $this->getAssigner($bundle);
67         $this->importFeature($io, $packages);
68     }
69
70     /**
71      * {@inheritdoc}
72      */
73     protected function interact(InputInterface $input, OutputInterface $output)
74     {
75         $io = new DrupalStyle($input, $output);
76
77         $packages = $input->getArgument('packages');
78         $bundle = $input->getOption('bundle');
79         
80         if (!$packages && !$bundle) {
81             // @see Drupal\Console\Command\Shared\FeatureTrait::packageQuestion
82             $bundle = $this->packageQuestion($io);
83             $input->setArgument('packages', $bundle);
84         }
85     }
86 }