_module_parse_info_file

Versions
5
_module_parse_info_file($filename)

Parse Drupal info file format. Uses ini parser provided by php's parse_ini_file().

Files should use the ini format to specify values. e.g. key = "value" key2 = value2

Some things to be aware of:

  • This function is NOT for placing arbitrary module-specific settings. Use variable_get() and variable_set() for that.
  • You may not use double-quotes in a value.

Information stored in the module.info file: name - The real name of the module for display purposes. description - A brief description of the module. dependencies - A space delimited list of the short names (shortname) of other modules this module depends on. package - The name of the package of modules this module belongs to.

Example of .info file: name = Forum description = Enables threaded discussions about general topics. dependencies = taxonomy comment package = Core - optional

Parameters

$filename The file we are parsing. Accepts file with relative or absolute path.

Return value

The info array.

▾ 4 functions call _module_parse_info_file()

help_page in modules/help/help.module
Menu callback; prints a page listing general help for all modules.
module_rebuild_cache in includes/module.inc
Rebuild the database cache of module files.
system_modules_uninstall in modules/system/system.module
Builds a form of currently disabled modules.
system_modules_uninstall_confirm_form in modules/system/system.module
Confirm uninstall of selected modules.

Code

includes/module.inc, line 190

<?php
function _module_parse_info_file($filename) {
  $info = array();

  if (file_exists($filename)) {
    $info = parse_ini_file($filename);

    if (isset($info['dependencies'])) {
      $info['dependencies'] = explode(" ", $info['dependencies']);
    }
    else {
      $info['dependencies'] = NULL;
    }
  }
  return $info;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.