function drush_sitealias_get_record

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

Get a site alias record given an alias name or site specification.

If it is the name of a site alias, return the alias record from the site aliases array.

If it is the name of a folder in the 'sites' folder, construct an alias record from values stored in settings.php.

If it is a site specification, construct an alias record from the values in the specification.

Site specifications come in several forms:

  • /path/to/drupal#sitename
  • user@server/path/to/drupal#sitename
  • user@server/path/to/drupal (sitename == server)
  • user@server#sitename (only if $option['r'] set in some drushrc file on server)
  • #sitename (only if $option['r'] already set, and 'sitename' is a folder in $option['r']/sites)
  • sitename (only if $option['r'] already set, and 'sitename' is a folder in $option['r']/sites)

Note that in the case of the first four forms, it is also possible to add additional site variable to the specification using uri query syntax. For example:

user@server/path/to/drupal?db-url=...#sitename

Parameters

alias: An alias name or site specification

Return value

array An alias record, or empty if none found.

22 calls to drush_sitealias_get_record()
drush_backend_invoke_concurrent in includes/backend.inc
Execute a new local or remote command in a new process.
drush_backend_output in includes/backend.inc
Print the json-encoded output of this command, including the encoded log records, context information, etc.
drush_core_execute in commands/core/core.drush.inc
Command callback. Execute specified shell code. Often used by shell aliases that start with !.
drush_early_complete in includes/complete.inc
Produce autocomplete output.
drush_process_bootstrap_to_first_arg in includes/command.inc
Process the --bootstrap-to-first-arg option, if it is present.

... See full list

File

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

Code

function drush_sitealias_get_record($alias, $alias_context = NULL) {
  // Check to see if the alias contains commas.  If it does, then
  // we will go ahead and make a site list record
  $alias_record = array();
  if (strpos($alias, ',') !== false) {
    // TODO:  If the site list contains any site lists, or site
    // search paths, then we should expand those and merge them
    // into this list longhand.
    $alias_record['site-list'] = explode(',', $alias);
  }
  else {
    $alias_record = _drush_sitealias_get_record($alias, $alias_context);
  }
  if (!empty($alias_record)) {
    if (!array_key_exists('#name', $alias_record)) {
      $alias_record['#name'] = drush_sitealias_uri_to_site_dir($alias);
    }

    // Handle nested alias definitions and command-specific options.
    drush_set_config_special_contexts($alias_record);
  }
  return $alias_record;
}