namespace Drupal\Console\Command\Shared;
-use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Zippy\Adapter\TarGzGNUTarForWindowsAdapter;
use Drupal\Console\Zippy\FileStrategy\TarGzFileForWindowsStrategy;
use Alchemy\Zippy\Zippy;
*/
trait ProjectDownloadTrait
{
- public function modulesQuestion(DrupalStyle $io)
+ public function modulesQuestion()
{
$moduleList = [];
->getList(true);
while (true) {
- $moduleName = $io->choiceNoList(
+ $moduleName = $this->getIo()->choiceNoList(
$this->trans('commands.module.install.questions.module'),
$modules,
- null,
+ '',
true
);
- if (empty($moduleName)) {
+ if (empty($moduleName) && is_numeric($moduleName)) {
break;
}
return $moduleList;
}
- public function modulesUninstallQuestion(DrupalStyle $io)
+ public function modulesUninstallQuestion()
{
$moduleList = [];
->getList(true);
while (true) {
- $moduleName = $io->choiceNoList(
+ $moduleName = $this->getIo()->choiceNoList(
$this->trans('commands.module.uninstall.questions.module'),
$modules,
- null,
+ '',
true
);
- if (empty($moduleName)) {
+ if (empty($moduleName) || is_numeric($modules)) {
break;
}
return $moduleList;
}
- private function downloadModules(DrupalStyle $io, $modules, $latest, $path = null, $resultList = [])
+ private function downloadModules($modules, $latest, $path = null, $resultList = [])
{
if (!$resultList) {
$resultList = [
$invalidModules = [];
if ($missingModules) {
- $io->info(
+ $this->getIo()->info(
sprintf(
$this->trans('commands.module.install.messages.getting-missing-modules'),
implode(', ', $missingModules)
)
);
foreach ($missingModules as $missingModule) {
- $version = $this->releasesQuestion($io, $missingModule, $latest);
+ $version = $this->releasesQuestion($missingModule, $latest);
if ($version) {
- $this->downloadProject($io, $missingModule, $version, 'module', $path);
+ $this->downloadProject($missingModule, $version, 'module', $path);
} else {
$invalidModules[] = $missingModule;
unset($modules[array_search($missingModule, $modules)]);
return $resultList;
}
- return $this->downloadModules($io, $dependencies, $latest, $path, $resultList);
+ return $this->downloadModules($dependencies, $latest, $path, $resultList);
}
protected function calculateDependencies($modules)
}
/**
- * @param \Drupal\Console\Core\Style\DrupalStyle $io
* @param $project
* @param $version
* @param $type
*
* @return string
*/
- public function downloadProject(DrupalStyle $io, $project, $version, $type, $path = null)
+ public function downloadProject($project, $version, $type, $path = null)
{
$commandKey = str_replace(':', '.', $this->getName());
- $io->comment(
+ $this->getIo()->comment(
sprintf(
$this->trans('commands.'.$commandKey.'.messages.downloading'),
$project,
if (!file_exists($projectPath)) {
if (!mkdir($projectPath, 0777, true)) {
- $io->error(
+ $this->getIo()->error(
sprintf(
$this->trans('commands.'.$commandKey.'.messages.error-creating-folder'),
$projectPath
unlink($destination);
if ($type != 'core') {
- $io->success(
+ $this->getIo()->success(
sprintf(
$this->trans(
'commands.' . $commandKey . '.messages.downloaded'
);
}
} catch (\Exception $e) {
- $io->error($e->getMessage());
+ $this->getIo()->error($e->getMessage());
return null;
}
}
/**
- * @param \Drupal\Console\Core\Style\DrupalStyle $io
* @param string $project
* @param bool $latest
* @param bool $stable
* @return string
*/
- public function releasesQuestion(DrupalStyle $io, $project, $latest = false, $stable = false)
+ public function releasesQuestion($project, $latest = false, $stable = false)
{
$commandKey = str_replace(':', '.', $this->getName());
- $io->comment(
+ $this->getIo()->comment(
sprintf(
$this->trans('commands.'.$commandKey.'.messages.getting-releases'),
implode(',', [$project])
$releases = $this->drupalApi->getProjectReleases($project, $latest?1:15, $stable);
if (!$releases) {
- $io->error(
+ $this->getIo()->error(
sprintf(
$this->trans('commands.'.$commandKey.'.messages.no-releases'),
implode(',', [$project])
return $releases[0];
}
- $version = $io->choice(
+ $version = $this->getIo()->choice(
$this->trans('commands.'.$commandKey.'.messages.select-release'),
$releases
);