You are here

function drush_modules_weight_mw_reorder in Modules weight 7

Same name and namespace in other branches
  1. 8.2 modules_weight.drush.inc \drush_modules_weight_mw_reorder()
  2. 8 modules_weight.drush.inc \drush_modules_weight_mw_reorder()

Callback for the mw-reorder command.

File

./modules_weight.drush.inc, line 190
Drush commands related to the Modules weight module.

Code

function drush_modules_weight_mw_reorder() {
  $args = func_get_args();

  // Loading the helper functions file.
  module_load_include('inc', 'modules_weight', 'modules_weight.helpers');
  if (count($args) == 2) {

    // Getting the --minus option.
    $minus = drush_get_option('minus');

    // Applying the minus option.
    $weight = $minus ? -1 * $args[1] : $args[1];

    // Setting the new weight.
    _modules_weight_module_set_weight($args[0], $weight);

    // Printing the message.
    $message = dt('The module weight for @module_name was updated to @weight.', array(
      '@module_name' => $args[0],
      '@weight' => $weight,
    ));
    drush_log($message, 'success');
  }
  else {

    // Searching for the module weigth.
    // Getting the module weight.
    $weight = _modules_weight_module_get_weight($args[0]);

    // Getting the module info.
    $module = system_get_info('module', $args[0]);

    // Creating the array with the sustitution values.
    $values = array(
      '@module_name' => $module['name'],
      '@machine_name' => $args[0],
      '@weight' => $weight,
    );
    $message = dt('The weight of the @module_name [@machine_name] module is: @weight', $values);
    drush_print($message);
  }
}