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;
*/
class InstallCommand extends Command
{
- use CommandTrait;
use ProjectDownloadTrait;
use ModuleTrait;
public function __construct(
Site $site,
Validator $validator,
- ModuleInstaller $moduleInstaller,
+ ModuleInstallerInterface $moduleInstaller,
DrupalApi $drupalApi,
Manager $extensionManager,
$appRoot,
null,
InputOption::VALUE_NONE,
$this->trans('commands.module.uninstall.options.composer')
- );
+ )
+ ->setAliases(['moi']);
}
/**
*/
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);
}
}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$module = $input->getArgument('module');
$latest = $input->getOption('latest');
$composer = $input->getOption('composer');
$this->site->loadLegacyFile('/core/includes/bootstrap.inc');
// check module's requirements
- $this->moduleRequirement($module, $io);
+ $this->moduleRequirement($module);
if ($composer) {
foreach ($module as $moduleItem) {
$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
)
);
$unInstalledModules = $module;
} else {
- $resultList = $this->downloadModules($io, $module, $latest);
+ $resultList = $this->downloadModules($module, $latest);
$invalidModules = $resultList['invalid'];
$unInstalledModules = $resultList['uninstalled'];
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
)
);
}
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)
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;
}