Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Module / InstallCommand.php
index 1d3f6da19c45a9464e1b9c4b27b743a9533f946a..5e164e6465b76ca58018cab6cbd643b436bbb6d4 100644 (file)
@@ -7,19 +7,17 @@
 
 namespace Drupal\Console\Command\Module;
 
-use Drupal\Console\Core\Command\Shared\CommandTrait;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Process\ProcessBuilder;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Command\Shared\ProjectDownloadTrait;
 use Drupal\Console\Command\Shared\ModuleTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 use Drupal\Console\Utils\Site;
 use Drupal\Console\Utils\Validator;
-use Drupal\Core\ProxyClass\Extension\ModuleInstaller;
+use Drupal\Core\Extension\ModuleInstallerInterface;
 use Drupal\Console\Utils\DrupalApi;
 use Drupal\Console\Extension\Manager;
 use Drupal\Console\Core\Utils\ChainQueue;
@@ -31,7 +29,6 @@ use Drupal\Console\Core\Utils\ChainQueue;
  */
 class InstallCommand extends Command
 {
-    use CommandTrait;
     use ProjectDownloadTrait;
     use ModuleTrait;
 
@@ -84,7 +81,7 @@ class InstallCommand extends Command
     public function __construct(
         Site $site,
         Validator $validator,
-        ModuleInstaller $moduleInstaller,
+        ModuleInstallerInterface $moduleInstaller,
         DrupalApi $drupalApi,
         Manager $extensionManager,
         $appRoot,
@@ -124,7 +121,8 @@ class InstallCommand extends Command
                 null,
                 InputOption::VALUE_NONE,
                 $this->trans('commands.module.uninstall.options.composer')
-            );
+            )
+            ->setAliases(['moi']);
     }
 
     /**
@@ -132,11 +130,9 @@ class InstallCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $module = $input->getArgument('module');
         if (!$module) {
-            $module = $this->modulesQuestion($io);
+            $module = $this->modulesQuestion();
             $input->setArgument('module', $module);
         }
     }
@@ -146,8 +142,6 @@ class InstallCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $module = $input->getArgument('module');
         $latest = $input->getOption('latest');
         $composer = $input->getOption('composer');
@@ -155,7 +149,7 @@ class InstallCommand extends Command
         $this->site->loadLegacyFile('/core/includes/bootstrap.inc');
 
         // check module's requirements
-        $this->moduleRequirement($module, $io);
+        $this->moduleRequirement($module);
 
         if ($composer) {
             foreach ($module as $moduleItem) {
@@ -172,16 +166,16 @@ class InstallCommand extends Command
                 $process->run();
 
                 if ($process->isSuccessful()) {
-                    $io->info(
+                    $this->getIo()->info(
                         sprintf(
-                            'Module %s was downloaded with Composer.',
+                            $this->trans('commands.module.install.messages.download-with-composer'),
                             $moduleItem
                         )
                     );
                 } else {
-                    $io->error(
+                    $this->getIo()->error(
                         sprintf(
-                            'Module %s seems not to be installed with Composer. Halting.',
+                            $this->trans('commands.module.install.messages.not-installed-with-composer'),
                             $moduleItem
                         )
                     );
@@ -191,7 +185,7 @@ class InstallCommand extends Command
 
             $unInstalledModules = $module;
         } else {
-            $resultList = $this->downloadModules($io, $module, $latest);
+            $resultList = $this->downloadModules($module, $latest);
 
             $invalidModules = $resultList['invalid'];
             $unInstalledModules = $resultList['uninstalled'];
@@ -199,9 +193,9 @@ class InstallCommand extends Command
             if ($invalidModules) {
                 foreach ($invalidModules as $invalidModule) {
                     unset($module[array_search($invalidModule, $module)]);
-                    $io->error(
+                    $this->getIo()->error(
                         sprintf(
-                            'Invalid module name: %s',
+                            $this->trans('commands.module.install.messages.invalid-name'),
                             $invalidModule
                         )
                     );
@@ -209,14 +203,14 @@ class InstallCommand extends Command
             }
 
             if (!$unInstalledModules) {
-                $io->warning($this->trans('commands.module.install.messages.nothing'));
+                $this->getIo()->warning($this->trans('commands.module.install.messages.nothing'));
 
                 return 0;
             }
         }
 
         try {
-            $io->comment(
+            $this->getIo()->comment(
                 sprintf(
                     $this->trans('commands.module.install.messages.installing'),
                     implode(', ', $unInstalledModules)
@@ -226,14 +220,14 @@ class InstallCommand extends Command
             drupal_static_reset('system_rebuild_module_data');
 
             $this->moduleInstaller->install($unInstalledModules, true);
-            $io->success(
+            $this->getIo()->success(
                 sprintf(
                     $this->trans('commands.module.install.messages.success'),
                     implode(', ', $unInstalledModules)
                 )
             );
         } catch (\Exception $e) {
-            $io->error($e->getMessage());
+            $this->getIo()->error($e->getMessage());
 
             return 1;
         }