function _drush_sitealias_prepare_record

8.0.x sitealias.drush.inc _drush_sitealias_prepare_record($alias_record)
6.x sitealias.drush.inc _drush_sitealias_prepare_record($alias_record, $site_alias = '')
7.x sitealias.drush.inc _drush_sitealias_prepare_record($alias_record)
master sitealias.drush.inc _drush_sitealias_prepare_record($alias_record)

Given a site alias name, print out a php-syntax representation of it.

Parameters

alias_record: The name of the site alias to print

2 calls to _drush_sitealias_prepare_record()
drush_sitealias_print in commands/core/sitealias.drush.inc
Print out the specified site aliases (or else all) using the format specified.
_drush_sitealias_print_record in commands/core/sitealias.drush.inc

File

commands/core/sitealias.drush.inc, line 211
Site alias commands.

Code

function _drush_sitealias_prepare_record($alias_record, $site_alias = '') {
  $output_db = drush_get_option('with-db');
  $output_db_url = drush_get_option('with-db-url');
  $output_optional_items = drush_get_option('with-optional');

  // Make sure that the default items have been added for all aliases
  _drush_sitealias_add_static_defaults($alias_record);

  // Include the optional items, if requested
  if ($output_optional_items) {
    _drush_sitealias_add_transient_defaults($alias_record);
  }

  drush_sitealias_resolve_path_references($alias_record);

  if (isset($output_db_url)) {
    drush_sitealias_add_db_url($alias_record);
  }
  if (isset($output_db_url) || isset($output_db)) {
    drush_sitealias_add_db_settings($alias_record);
  }
  // If the user specified --with-db-url, then leave the
  // 'db-url' entry in the alias record (unless it is not
  // set, in which case we will leave the 'databases' record instead).
  if (isset($output_db_url)) {
    if (isset($alias_record['db-url'])) {
      unset($alias_record['databases']);
    }
  }
  // If the user specified --with-db, then leave the
  // 'databases' entry in the alias record.
  else if (isset($output_db)) {
    unset($alias_record['db-url']);
  }
  // If neither --with-db nor --with-db-url were specified,
  // then remove both the 'db-url' and the 'databases' entries.
  else {
    unset($alias_record['db-url']);
    unset($alias_record['databases']);
  }

  // The alias name will be the same as the site alias name,
  // unless the user specified some other name on the command line.
  $alias_name = drush_get_option('alias-name');
  if (!isset($alias_name)) {
    $alias_name = $site_alias;
    if (empty($alias_name) || is_numeric($alias_name)) {
      $alias_name = drush_sitealias_uri_to_site_dir($alias_record['uri']);
    }
  }

  // We don't want certain fields to go into the output
  unset($alias_record['#group']);
  unset($alias_record['#hidden']);

  // We only want to output the 'root' item; don't output the '%root' path alias
  if (array_key_exists('path-aliases', $alias_record) && array_key_exists('%root', $alias_record['path-aliases'])) {
    unset($alias_record['path-aliases']['%root']);
    // If there is nothing left in path-aliases, then clear it out
    if (count($alias_record['path-aliases']) == 0) {
      unset($alias_record['path-aliases']);
    }
  }

  // Alias names contain an '@' when referenced, but do
  // not contain an '@' when defined.
  if (substr($alias_name, 0, 1) == '@') {
    $alias_name = substr($alias_name, 1);
  }

  return array($alias_name, $alias_record);
}