X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FModule%2FInstallDependencyCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FModule%2FInstallDependencyCommand.php;h=56ca8694a379513fa71ac790d60ccc6675972dc9;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Module/InstallDependencyCommand.php b/vendor/drupal/console/src/Command/Module/InstallDependencyCommand.php new file mode 100644 index 000000000..56ca8694a --- /dev/null +++ b/vendor/drupal/console/src/Command/Module/InstallDependencyCommand.php @@ -0,0 +1,145 @@ +site = $site; + $this->validator = $validator; + $this->moduleInstaller = $moduleInstaller; + $this->chainQueue = $chainQueue; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('module:dependency:install') + ->setDescription($this->trans('commands.module.install.dependencies.description')) + ->addArgument( + 'module', + InputArgument::IS_ARRAY, + $this->trans('commands.module.install.dependencies.arguments.module') + ); + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $module = $input->getArgument('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setArgument('module', $module); + } + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $module = $input->getArgument('module'); + $unInstalledDependencies = $this->calculateDependencies((array)$module); + + if (!$unInstalledDependencies) { + $io->warning($this->trans('commands.module.install.dependencies.messages.no-depencies')); + return 0; + } + + try { + $io->comment( + sprintf( + $this->trans('commands.module.install.dependencies.messages.installing'), + implode(', ', $unInstalledDependencies) + ) + ); + + drupal_static_reset('system_rebuild_module_data'); + + $this->moduleInstaller->install($unInstalledDependencies, true); + $io->success( + sprintf( + $this->trans('commands.module.install.dependencies.messages.success'), + implode(', ', $unInstalledDependencies) + ) + ); + } catch (\Exception $e) { + $io->error($e->getMessage()); + + return 1; + } + + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + } +}