You are here

function _system_info_add_path in Drupal 7

Prefixes all values in an .info file array with a given path.

This helper function is mainly used to prefix all array values of an .info file property with a single given path (to the module or theme); e.g., to prefix all values of the 'stylesheets' or 'scripts' properties with the file path to the defining module/theme.

Parameters

$info: A nested array of data of an .info file to be processed.

$path: A file path to prepend to each value in $info.

Return value

The $info array with prefixed values.

See also

_system_rebuild_module_data()

_system_rebuild_theme_data()

2 calls to _system_info_add_path()
_system_rebuild_module_data in modules/system/system.module
Helper function to scan and collect module .info data.
_system_rebuild_theme_data in modules/system/system.module
Helper function to scan and collect theme .info data and their engines.

File

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

Code

function _system_info_add_path($info, $path) {
  foreach ($info as $key => $value) {

    // Recurse into nested values until we reach the deepest level.
    if (is_array($value)) {
      $info[$key] = _system_info_add_path($info[$key], $path);
    }
    else {
      unset($info[$key]);
      $info[$value] = $path . '/' . $value;
    }
  }
  return $info;
}