-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding setup:toggle-modules command.
- Loading branch information
Showing
6 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Acquia\Blt\Robo\Commands\Setup; | ||
|
||
use Acquia\Blt\Robo\BltTasks; | ||
use Robo\Contract\VerbosityThresholdInterface; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* Defines commands in the "setup:toggle-modules" namespace. | ||
*/ | ||
class ToggleModulesCommand extends BltTasks { | ||
|
||
/** | ||
* Enables and uninstalls specified modules. | ||
* | ||
* @command setup:toggle-modules | ||
*/ | ||
public function toggleModules() { | ||
if (!empty($_ENV['environment'])) { | ||
// Enable modules. | ||
$enable_key = "modules.{$_ENV['environment']}.enable"; | ||
$exit_code = $this->doToggleModules('pm-enable', $enable_key); | ||
|
||
// Uninstall modules. | ||
$disable_key = "modules.{$_ENV['environment']}.uninstall"; | ||
$exit_code = $this->doToggleModules('pm-uninstall', $disable_key); | ||
|
||
return $exit_code; | ||
} | ||
} | ||
|
||
/** | ||
* Enables or uninstalls an array of modules. | ||
* | ||
* @param string $command | ||
* The drush command to execute. E.g., pm-enable or pm-uninstall. | ||
* @param string $config_key | ||
* The config key containing the array of modules. | ||
* | ||
* @return int | ||
* The exit code of the command. | ||
*/ | ||
protected function doToggleModules($command, $config_key) { | ||
if ($this->getConfig()->has($config_key)) { | ||
$modules = $this->getConfigValue($config_key); | ||
$modules_list = implode(' ', $modules); | ||
$result = $this->taskDrush() | ||
->drush("$command $modules_list --skip") | ||
->run(); | ||
$exit_code = $result->getExitCode(); | ||
} | ||
else { | ||
$exit_code = 0; | ||
$this->logger->info("$config_key is not set."); | ||
} | ||
|
||
return $exit_code; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters