You are here

function libraries_scan_info_files in Libraries API 7.3

Same name and namespace in other branches
  1. 8.3 libraries.module \libraries_scan_info_files()
  2. 7.2 libraries.module \libraries_scan_info_files()

Looks for library info files.

This function scans the following directories for info files:

  • libraries
  • profiles/$profilename/libraries
  • sites/all/libraries
  • sites/$sitename/libraries
  • any directories specified via hook_libraries_info_file_paths()

Return value

An array of info files, keyed by library name. The values are the paths of the files.

2 calls to libraries_scan_info_files()
LibrariesTestCase::testLibrariesScanInfoFiles in tests/libraries.test
Tests libraries_scan_info_files().
libraries_info in ./libraries.module
Returns information about registered libraries.

File

./libraries.module, line 182
External library handling for Drupal modules.

Code

function libraries_scan_info_files() {
  $profile = drupal_get_path('profile', drupal_get_profile());
  $config = conf_path();

  // Build a list of directories.
  $directories = module_invoke_all('libraries_info_file_paths');
  $directories[] = 'libraries';
  $directories[] = "{$profile}/libraries";
  $directories[] = 'sites/all/libraries';
  $directories[] = "{$config}/libraries";

  // Scan for info files.
  $files = array();
  foreach ($directories as $dir) {
    if (file_exists($dir)) {
      $files = array_merge($files, file_scan_directory($dir, '@^[A-Za-z0-9._-]+\\.libraries\\.info$@', array(
        'key' => 'name',
        'recurse' => FALSE,
      )));
    }
  }
  foreach ($files as $filename => $file) {
    $files[basename($filename, '.libraries')] = $file;
    unset($files[$filename]);
  }
  return $files;
}