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 208
Site alias commands.

Code

function _drush_sitealias_prepare_record($alias_record) {
  $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) || 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'])) {
      $alias_record['db-url'] = drush_sitealias_convert_databases_to_db_url($alias_record['databases']);
    }
    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']);
  }

  // We don't want certain fields to go into the output
  if (!drush_get_option('show-hidden')) {
    foreach ($alias_record as $key => $value) {
      if ($key[0] == '#') {
        unset($alias_record[$key]);
      }
    }
  }

  // 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']);
    }
  }

  return $alias_record;
}