8.5.x system.module system_get_info($type, $name = NULL)
8.0.x system.module system_get_info($type, $name = NULL)
8.1.x system.module system_get_info($type, $name = NULL)
8.2.x system.module system_get_info($type, $name = NULL)
8.3.x system.module system_get_info($type, $name = NULL)
8.4.x system.module system_get_info($type, $name = NULL)
8.6.x system.module system_get_info($type, $name = NULL)
7.x system.module system_get_info($type, $name = NULL)

Returns an array of information about enabled modules or themes.

This function returns the information from the {system} table corresponding to the cached contents of the .info file for each active module or theme.

Parameters

$type: Either 'module' or 'theme'.

$name: (optional) The name of a module or theme whose information shall be returned. If omitted, all records for the provided $type will be returned. If $name does not exist in the provided $type or is not enabled, an empty array will be returned.

Return value

An associative array of module or theme information keyed by name, or only information for $name, if given. If no records are available, an empty array is returned.

See also

system_rebuild_module_data()

system_rebuild_theme_data()

7 calls to system_get_info()
help_page in modules/help/help.admin.inc
Menu callback; prints a page listing general help for a module.
ModuleRequiredTestCase::testDisableRequired in modules/system/system.test
Assert that core required modules cannot be disabled.
system_admin_index in modules/system/system.admin.inc
Menu callback; prints a listing of admin tasks, organized by module.
system_requirements in modules/system/system.install
Implements hook_requirements().
user_admin_permissions in modules/user/user.admin.inc
Menu callback: administer permissions.

... See full list

File

modules/system/system.module, line 2344
Configuration system that lets administrators modify the workings of the site.

Code

function system_get_info($type, $name = NULL) {
  $info = array();
  if ($type == 'module') {
    $type = 'module_enabled';
  }
  $list = system_list($type);
  foreach ($list as $shortname => $item) {
    if (!empty($item->status)) {
      $info[$shortname] = $item->info;
    }
  }
  if (isset($name)) {
    return isset($info[$name]) ? $info[$name] : array();
  }
  return $info;
}

Comments

dvessel’s picture

Beware! If the theme is hidden, it will never be in the active list of themes so $item->status will always return false. Doesn’t mean it can’t be running since sub-themes can point to hidden base themes. In effect, this function has no access to the theme info data for hidden themes.

You can access through list_themes() instead:


$themes = list_themes();
$info = $themes[$name]->info;

nithinkolekar’s picture

can we get current module info by context without specifying module name?
ex : if we have module called mymodule and if we want to get current version inside mymodule.module, shall we still need to specify module name?