Skip to content

Commit

Permalink
Fix module:install command (#2748)
Browse files Browse the repository at this point in the history
  • Loading branch information
enzolutions authored Sep 30, 2016
1 parent b7392bd commit 309e12a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/services/drupal-console/module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- { name: drupal.command }
module_install:
class: Drupal\Console\Command\Module\InstallCommand
arguments: ['@console.site', '@console.validator', '@module_installer', '@console.chain_queue']
arguments: ['@console.site', '@console.validator', '@module_installer', '@console.drupal_api', '@console.extension_manager', '@app.root', '@console.chain_queue']
tags:
- { name: drupal.command }
module_path:
Expand Down
22 changes: 22 additions & 0 deletions src/Command/Module/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Drupal\Console\Utils\Site;
use Drupal\Console\Utils\Validator;
use Drupal\Core\ProxyClass\Extension\ModuleInstaller;
use Drupal\Console\Utils\DrupalApi;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Utils\ChainQueue;

/**
Expand All @@ -42,6 +44,17 @@ class InstallCommand extends Command
/** @var ModuleInstaller */
protected $moduleInstaller;

/** @var DrupalApi */
protected $drupalApi;

/** @var Manager */
protected $extensionManager;

/**
* @var string
*/
protected $appRoot;

/**
* @var ChainQueue
*/
Expand All @@ -52,17 +65,26 @@ class InstallCommand extends Command
* @param Site $site
* @param Validator $validator
* @param ModuleInstaller $moduleInstaller
* @param DrupalApi $drupalApi
* @param Manager $extensionManager
* @param $appRoot
* @param ChainQueue $chainQueue
*/
public function __construct(
Site $site,
Validator $validator,
ModuleInstaller $moduleInstaller,
DrupalApi $drupalApi,
Manager $extensionManager,
$appRoot,
ChainQueue $chainQueue
) {
$this->site = $site;
$this->validator = $validator;
$this->moduleInstaller = $moduleInstaller;
$this->drupalApi = $drupalApi;
$this->extensionManager = $extensionManager;
$this->appRoot = $appRoot;
$this->chainQueue = $chainQueue;
parent::__construct();
}
Expand Down
8 changes: 6 additions & 2 deletions src/Command/Shared/ProjectDownloadTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public function downloadProject(DrupalStyle $io, $project, $version, $type, $pat

try {
$destination = $this->drupalApi->downloadProjectRelease(
$this->httpClient,
$project,
$version
);
Expand All @@ -192,7 +191,12 @@ public function downloadProject(DrupalStyle $io, $project, $version, $type, $pat

if (!file_exists($projectPath)) {
if (!mkdir($projectPath, 0777, true)) {
$io->error($this->trans('commands.'.$commandKey.'.messages.error-creating-folder') . ': ' . $projectPath);
$io->error(
sprintf(
$this->trans('commands.'.$commandKey.'.messages.error-creating-folder'),
$projectPath
)
);
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/DrupalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getProjectReleases($module, $limit = 10, $stable = false)
public function downloadProjectRelease($project, $release, $destination = null)
{
if (!$release) {
$releases = $this->getProjectReleases($this->httpClient, $project, 1);
$releases = $this->getProjectReleases($project, 1);
$release = current($releases);
}

Expand All @@ -215,7 +215,7 @@ public function downloadProjectRelease($project, $release, $destination = null)
$release
);

if ($this->downloadFile($this->httpClient, $releaseFilePath, $destination)) {
if ($this->downloadFile($releaseFilePath, $destination)) {
return $destination;
}

Expand Down

0 comments on commit 309e12a

Please sign in to comment.