function module_set_weight

Sets weight of a particular module.

The weight of uninstalled modules cannot be changed.

Parameters

string $module: The name of the module (without the .module extension).

int $weight: An integer representing the weight of the module.

8 calls to module_set_weight()

File

drupal/core/includes/module.inc, line 1214
API for loading and interacting with Drupal modules.

Code

function module_set_weight($module, $weight) {

  // Update the module weight in the config file that contains it.
  $module_config = config('system.module');
  if ($module_config
    ->get("enabled.{$module}") !== NULL) {
    $module_config
      ->set("enabled.{$module}", $weight)
      ->set('enabled', module_config_sort($module_config
      ->get('enabled')))
      ->save();
    return;
  }
  $disabled_config = config('system.module.disabled');
  if ($disabled_config
    ->get($module) !== NULL) {
    $disabled_config
      ->set($module, $weight)
      ->save();
    return;
  }
}