function drush_modules_weight_mw_reorder_validate in Modules weight 7
Same name and namespace in other branches
- 8.2 modules_weight.drush.inc \drush_modules_weight_mw_reorder_validate()
- 8 modules_weight.drush.inc \drush_modules_weight_mw_reorder_validate()
Implements drush_hook_COMMAND_validate().
File
- ./
modules_weight.drush.inc, line 159 - Drush commands related to the Modules weight module.
Code
function drush_modules_weight_mw_reorder_validate() {
$args = func_get_args();
// Check for 1 or 2 arguments.
if (count($args) < 1 || count($args) > 2) {
return drush_set_error('MODULES_WEIGHT_INVALID_ARGUMENT', dt('This command use one or two arguments.'));
}
// Check for a valid or installed module machine name.
if (!module_exists($args[0])) {
return drush_set_error('MODULES_WEIGHT_INVALID_MODULE_NAME', dt('@module_name module machine name is invalid or is not installed.', array(
'@module_name' => $args[0],
)));
}
// Check for integer number.
if (isset($args[1]) && !ctype_digit($args[1])) {
return drush_set_error('MODULES_WEIGHT_INVALID_ARGUMENT', dt('You must enter digits for the modules-weight.'));
}
// Getting the --force option.
$force = drush_get_option('force');
// Getting the module info.
$module = system_get_info('module', $args[0]);
// Getting the config to know of we should show or not the core modules.
$show_system_modules = variable_get('modules_weight_show_system_modules');
// Checking if we can reorder the Core modules.
if (!$force && $module['package'] == 'Core' && !$show_system_modules) {
if (!drush_confirm(dt("You're trying to reorder a Core module but Modules Weight is not configured to allow it. Do you want to continue?"))) {
return drush_user_abort();
}
}
}