Skip to content

Commit

Permalink
[module:install] Respect hook_requirements (#2513)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel303 authored and jmolivas committed Jul 14, 2016
1 parent e703fb1 commit 8c967f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Command/Module/InstallCommand.php
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Command\Shared\ProjectDownloadTrait;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Style\DrupalStyle;

/**
Expand All @@ -24,6 +25,7 @@ class InstallCommand extends Command
{
use ContainerAwareCommandTrait;
use ProjectDownloadTrait;
use ModuleTrait;

/**
* {@inheritdoc}
Expand Down Expand Up @@ -78,6 +80,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$composer = $input->getOption('composer');

$this->get('site')->loadLegacyFile('core/includes/bootstrap.inc');

// check module's requirements
$this->moduleRequirement($module);

if ($composer) {
foreach ($module as $moduleItem) {
Expand Down
14 changes: 14 additions & 0 deletions src/Command/Shared/ModuleTrait.php
Expand Up @@ -40,4 +40,18 @@ public function moduleQuestion(DrupalStyle $io, $showProfile = true)

return $module;
}

public function moduleRequirement($module)
{
foreach ($module as $module_name) {
module_load_install($module_name);

if ($requirements = \Drupal::moduleHandler()->invoke($module_name, 'requirements', array('install'))) {
foreach ($requirements as $requirement) {
throw new \Exception($module_name .' can not be installed: ' . $requirement['description']);
}
}
}
}

}

0 comments on commit 8c967f6

Please sign in to comment.