5 * Contains \Drupal\Console\Command\Module\InstallDependencyCommand.
8 namespace Drupal\Console\Command\Module;
10 use Drupal\Console\Core\Command\Shared\CommandTrait;
11 use Symfony\Component\Console\Input\InputArgument;
12 use Symfony\Component\Console\Input\InputOption;
13 use Symfony\Component\Console\Input\InputInterface;
14 use Symfony\Component\Console\Output\OutputInterface;
15 use Symfony\Component\Console\Command\Command;
16 use Drupal\Console\Command\Shared\ProjectDownloadTrait;
17 use Drupal\Console\Command\Shared\ModuleTrait;
18 use Drupal\Console\Core\Style\DrupalStyle;
19 use Drupal\Console\Utils\Site;
20 use Drupal\Console\Utils\Validator;
21 use Drupal\Core\ProxyClass\Extension\ModuleInstaller;
22 use Drupal\Console\Core\Utils\ChainQueue;
25 * Class InstallDependencyCommand
27 * @package Drupal\Console\Command\Module
29 class InstallDependencyCommand extends Command
32 use ProjectDownloadTrait;
46 * @var ModuleInstaller
48 protected $moduleInstaller;
53 protected $chainQueue;
56 * InstallCommand constructor.
59 * @param Validator $validator
60 * @param ChainQueue $chainQueue
62 public function __construct(
65 ModuleInstaller $moduleInstaller,
66 ChainQueue $chainQueue
69 $this->validator = $validator;
70 $this->moduleInstaller = $moduleInstaller;
71 $this->chainQueue = $chainQueue;
72 parent::__construct();
78 protected function configure()
81 ->setName('module:dependency:install')
82 ->setDescription($this->trans('commands.module.install.dependencies.description'))
85 InputArgument::IS_ARRAY,
86 $this->trans('commands.module.install.dependencies.arguments.module')
93 protected function interact(InputInterface $input, OutputInterface $output)
95 $io = new DrupalStyle($input, $output);
97 $module = $input->getArgument('module');
99 // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
100 $module = $this->moduleQuestion($io);
101 $input->setArgument('module', $module);
108 protected function execute(InputInterface $input, OutputInterface $output)
110 $io = new DrupalStyle($input, $output);
112 $module = $input->getArgument('module');
113 $unInstalledDependencies = $this->calculateDependencies((array)$module);
115 if (!$unInstalledDependencies) {
116 $io->warning($this->trans('commands.module.install.dependencies.messages.no-depencies'));
123 $this->trans('commands.module.install.dependencies.messages.installing'),
124 implode(', ', $unInstalledDependencies)
128 drupal_static_reset('system_rebuild_module_data');
130 $this->moduleInstaller->install($unInstalledDependencies, true);
133 $this->trans('commands.module.install.dependencies.messages.success'),
134 implode(', ', $unInstalledDependencies)
137 } catch (\Exception $e) {
138 $io->error($e->getMessage());
143 $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);