function _drush_sitealias_find_alias_files

8.0.x sitealias.inc _drush_sitealias_find_alias_files($aliasname = NULL, $alias_path_context = NULL)
6.x sitealias.inc _drush_sitealias_find_alias_files($aliasname = NULL, $alias_path_context = NULL)
7.x sitealias.inc _drush_sitealias_find_alias_files($aliasname = NULL, $alias_path_context = NULL)
5.x sitealias.inc _drush_sitealias_find_alias_files($aliasname = NULL, $alias_path_context = NULL)
master sitealias.inc _drush_sitealias_find_alias_files($aliasname = NULL, $alias_path_context = NULL)

Function to find all alias files that might contain aliases that match the requested alias name.

3 calls to _drush_sitealias_find_alias_files()
_core_site_status_table in commands/core/core.drush.inc
_drush_sitealias_find_and_load_alias in includes/sitealias.inc
Traverses the alias search path and finds the specified alias record.
_drush_sitealias_find_and_load_all_aliases in includes/sitealias.inc
Worker function called by _drush_sitealias_load_alias and drush_sitealias_load_all. Traverses the alias search path and finds the specified alias record.

File

includes/sitealias.inc, line 612
The site alias API.

Code

function _drush_sitealias_find_alias_files($aliasname = NULL, $alias_path_context = NULL) {
  $alias_files_to_consider = array();

  // The alias path is a list of folders to search for alias settings files
  $alias_path = drush_sitealias_alias_path($alias_path_context);

  // $alias_files contains a list of filename patterns
  // to search for.  We will find any matching file in
  // any folder in the alias path.  The directory scan
  // is not deep, though; only files immediately in the
  // search path are considered.
  $alias_files = array('/.*aliases\.drush(' . DRUSH_MAJOR_VERSION . '|)rc\.php$/');
  if ($aliasname == NULL) {
    $alias_files[] = '/.*\.alias\.drush(' . DRUSH_MAJOR_VERSION . '|)rc\.php$/';
  }
  else {
    $alias_files[] = '/' . preg_quote($aliasname, '/') . '\.alias\.drush(' . DRUSH_MAJOR_VERSION . '|)rc\.php$/';
  }

  // Do not scan into the files directory.
  $blacklist = array_merge(array('files'), drush_filename_blacklist());

  // Search each path in turn.
  foreach ($alias_path as $path) {
    // Find all of the matching files in this location
    foreach ($alias_files as $file_pattern_to_search_for) {
      drush_log(dt('Scanning into @path for @pattern', array('@path' => $path, '@pattern' => $file_pattern_to_search_for)), LogLevel::DEBUG);
      $alias_files_to_consider = array_merge($alias_files_to_consider, array_keys(drush_scan_directory($path, $file_pattern_to_search_for, $blacklist, 0, TRUE)));
    }
  }

  return $alias_files_to_consider;
}