5 * Contains \Drupal\Console\Command\Module\InstallDependencyCommand.
8 namespace Drupal\Console\Command\Module;
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\Core\Command\Command;
15 use Drupal\Console\Command\Shared\ProjectDownloadTrait;
16 use Drupal\Console\Command\Shared\ModuleTrait;
17 use Drupal\Console\Utils\Site;
18 use Drupal\Console\Utils\Validator;
19 use Drupal\Core\Extension\ModuleInstallerInterface;
20 use Drupal\Console\Core\Utils\ChainQueue;
23 * Class InstallDependencyCommand
25 * @package Drupal\Console\Command\Module
27 class InstallDependencyCommand extends Command
29 use ProjectDownloadTrait;
43 * @var ModuleInstallerInterface
45 protected $moduleInstaller;
50 protected $chainQueue;
53 * InstallCommand constructor.
56 * @param Validator $validator
57 * @param ModuleInstallerInterface $moduleInstaller
58 * @param ChainQueue $chainQueue
60 public function __construct(
63 ModuleInstallerInterface $moduleInstaller,
64 ChainQueue $chainQueue
67 $this->validator = $validator;
68 $this->moduleInstaller = $moduleInstaller;
69 $this->chainQueue = $chainQueue;
70 parent::__construct();
76 protected function configure()
79 ->setName('module:dependency:install')
80 ->setDescription($this->trans('commands.module.dependency.install.description'))
83 InputArgument::IS_ARRAY,
84 $this->trans('commands.module.dependency.install.arguments.module')
85 )->setAliases(['modi']);
91 protected function interact(InputInterface $input, OutputInterface $output)
93 $module = $input->getArgument('module');
95 // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
96 $module = $this->moduleQuestion();
97 $input->setArgument('module', $module);
104 protected function execute(InputInterface $input, OutputInterface $output)
106 $module = $input->getArgument('module');
107 $unInstalledDependencies = $this->calculateDependencies((array)$module);
109 if (!$unInstalledDependencies) {
110 $this->getIo()->warning($this->trans('commands.module.dependency.install.messages.no-depencies'));
115 $this->getIo()->comment(
117 $this->trans('commands.module.dependency.install.messages.installing'),
118 implode(', ', $unInstalledDependencies)
122 drupal_static_reset('system_rebuild_module_data');
124 $this->moduleInstaller->install($unInstalledDependencies, true);
125 $this->getIo()->success(
127 $this->trans('commands.module.dependency.install.messages.success'),
128 implode(', ', $unInstalledDependencies)
131 } catch (\Exception $e) {
132 $this->getIo()->error($e->getMessage());
137 $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);