9

Is there any function in Drupal like get_module_info('MODULE_NAME') or I should parse info file?

apaderno
  • 28,547
  • 16
  • 75
  • 90
sultan
  • 5,978
  • 14
  • 59
  • 103

3 Answers3

15

drupal_parse_info_file() is the closest function, but it takes a file path, not a module name, so you have to convert the name into the path first:

$path = drupal_get_path('module', $name) . '/' . $name . '.info';
$info = drupal_parse_info_file($path);
apaderno
  • 28,547
  • 16
  • 75
  • 90
Scott Reynen
  • 3,530
  • 18
  • 17
7

A somewhat easier method (drupal 7 and up) is to use the system_get_info function.

acrollet
  • 921
  • 7
  • 6
5

If you happen to be using the Features module, it has created a solid structure for interacting with the System table that is readily adaptable for any module info gathering.

To get information about a module, use features_get_modules($module_name). This dispatches a module-specific request to features_get_info() on line 475 of features.module.

The information is cached, and you can make use of hook_system_info_alter() to modify the values you need. Note that this functionality is not touched by anything in Drupal core, and is only useful for your own custom module functionality.

Grayside
  • 4,144
  • 21
  • 25