Skip to content

Commit

Permalink
#2494 - Validate module uninstall validity. (#2693)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman authored Mar 27, 2017
1 parent e0389b4 commit 7a2b5a3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Commands/PmCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Drush\Commands;


use Consolidation\AnnotatedCommand\CommandData;
use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\MissingDependencyException;
Expand Down Expand Up @@ -63,6 +64,23 @@ public function uninstall($modules) {
$boot->add_logger();
}

/**
* @hook validate pm-uninstall
*/
public function validateUninstall(CommandData $commandData) {
if ($modules = $commandData->input()->getArgument('modules')) {
$modules = _convert_csv_to_array($modules);
if ($validation_reasons = \Drupal::service('module_installer')->validateUninstall($modules)) {
foreach ($validation_reasons as $module => $list) {
foreach ($list as $markup) {
$reasons[$module] = "$module: " . (string) $markup;
}
}
throw new \Exception(implode("/n", $reasons));
}
}
}

/**
* Show a list of available extensions (modules and themes).
*
Expand Down

0 comments on commit 7a2b5a3

Please sign in to comment.