diff --git a/core/includes/module.inc b/core/includes/module.inc index ff11244..96a11a0 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -201,6 +201,30 @@ function drupal_required_modules() { } /** + * Gets weight of a particular module. + * + * @param string $module + * The name of the module (without the .module extension). + * + * @return integer + * The configured weight of the module. + * + * @throws InvalidArgumentException + * Thrown in case the given module is not installed in the system. + */ +function module_get_weight($module) { + $weight = \Drupal::config('system.module')->get("enabled.$module"); + if ($weight !== NULL) { + return (int) $weight; + } + $weight = \Drupal::config('system.module.disabled')->get($module); + if ($weight !== NULL) { + return (int) $weight; + } + throw new InvalidArgumentException(format_string('The module %module is not installed.', array('%module' => $module))); +} + +/** * Sets weight of a particular module. * * The weight of uninstalled modules cannot be changed.