1 system.module _system_info_add_path($info, $path)

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.


$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




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


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);
    // Unset the original value's key and set the new value with prefix, using
    // the original value as key, so original values can still be looked up.
    else {
      $info[$value] = $path . '/' . $value;
  return $info;