function _drush_sitealias_load_alias

8.0.x sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)
6.x sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)
7.x sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)
3.x sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)
4.x sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)
5.x sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)
master sitealias.inc _drush_sitealias_load_alias($alias, $alias_path_context = NULL)

Check and see if an alias definition for $alias is available. If it is, load it into the list of aliases cached in the 'site-aliases' context.

Parameters

$alias: The name of the alias to load in ordinary form ('@name')

$alias_path_context: When looking up a relative alias, the alias path context is the primary alias that we will start our search from.

1 call to _drush_sitealias_load_alias()

File

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

Code

function _drush_sitealias_load_alias($alias, $alias_path_context = NULL) {
  $all_site_aliases = drush_get_context('site-aliases');
  $result = array();

  // Check to see if this is a relative alias ('@site/@peer')
  $relative_alias_pos = strpos($alias, '/@');
  if ($relative_alias_pos !== false) {
    $primary_alias = substr($alias, 0, $relative_alias_pos);
    $relative_alias = substr($alias, $relative_alias_pos + 1);
    $primary_record = drush_sitealias_get_record($primary_alias);
    _drush_sitealias_find_and_load_alias(substr($relative_alias, 1), $primary_record);
    $result = drush_sitealias_get_record($relative_alias);
    if (!empty($result)) {
      if (array_key_exists('inherited', $result)) {
        $result = array_merge($primary_record, $result);
      }
      $result['name'] = $relative_alias;
      _drush_sitealias_cache_alias(substr($alias, 1), $result);
    }
  }
  else {
    // Only aliases--those named entities that begin with '@'--can be loaded this way.
    // We also skip any alias that has already been loaded.
    if ((substr($alias, 0, 1) == '@') && !array_key_exists($alias, $all_site_aliases)) {
      drush_log(dt('Load alias !alias', array('!alias' => $alias)));
      $aliasname = substr($alias, 1);
      $result = _drush_sitealias_find_and_load_alias($aliasname, $alias_path_context);
      if (!empty($result)) {
        $alias_options = array('site-aliases' => array($aliasname => $result));
        _drush_sitealias_add_inherited_values($alias_options['site-aliases']);
        drush_set_config_special_contexts($alias_options);
      }
    }
  }

  return $result;
}