function drush_sitealias_alias_record_to_spec

8.0.x sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)
6.x sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)
7.x sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)
3.x sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)
4.x sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)
5.x sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)
master sitealias.inc drush_sitealias_alias_record_to_spec($alias_record, $with_db = false)

Convert from an alias record to a site specification

Parameters

alias_record: The full alias record to convert

with_db: True if the site specification should include a ?db-url term

Return value

string The site specification

3 calls to drush_sitealias_alias_record_to_spec()
drush_do_multiple_command in includes/drush.inc
Used by functions that operate on lists of sites, moving information from the source to the destination. Currenlty this includes 'drush rsync' and 'drush sql sync'.
drush_sitealias_print in commands/core/sitealias.drush.inc
Print out the specified site aliases using the format specified.
_drush_sitealias_initialize_alias_record in includes/sitealias.inc
Initialize an alias record; called as soon as the alias record is loaded from its alias file, before it is stored in the cache.

File

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

Code

function drush_sitealias_alias_record_to_spec($alias_record, $with_db = false) {
  $result = '';

  // TODO:  we should handle 'site-list' records too.
  if (array_key_exists('site-list', $alias_record)) {
    // TODO:  we should actually expand the site list and recompose it
    $result = implode(',', $alias_record['site-list']);
  }
  else {
    // There should always be a uri
    if (array_key_exists('uri', $alias_record)) {
      $result = '#' . drush_sitealias_uri_to_site_dir($alias_record['uri']);
    }
    // There should always be a root
    if (array_key_exists('root', $alias_record)) {
      $result = $alias_record['root'] . $result;
    }
    if (array_key_exists('remote-host', $alias_record)) {
      $result = $alias_record['remote-host'] . $result;
      if (array_key_exists('remote-user', $alias_record)) {
        $result = $alias_record['remote-user'] . '@' . $result;
      }
    }

    // add the database info to the specification if desired
    if ($with_db) {
      $result = $result . '?db-url=' . urlencode($alias_record['db-url']);
    }
  }

  return $result;
}