function drush_sitealias_bootstrapped_site_name

8.0.x sitealias.inc drush_sitealias_bootstrapped_site_name()
6.x sitealias.inc drush_sitealias_bootstrapped_site_name()
7.x sitealias.inc drush_sitealias_bootstrapped_site_name()
5.x sitealias.inc drush_sitealias_bootstrapped_site_name()
master sitealias.inc drush_sitealias_bootstrapped_site_name()

Get the name of the current bootstrapped site

File

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

Code

function drush_sitealias_bootstrapped_site_name() {
  $site_name = NULL;
  $self_record = drush_sitealias_get_record('@self');
  if (array_key_exists('#name', $self_record)) {
    $site_name = $self_record['#name'];
  }
  if (!isset($site_name) || ($site_name == '@self')) {
    $drupal_root = \Drush::bootstrapManager()->getRoot();
    if (isset($drupal_root)) {
      $drupal_uri = drush_get_context('DRUSH_SELECTED_URI', 'default');
      $drupal_uri = str_replace('http://', '', $drupal_uri);
      // TODO: Maybe use _drush_sitealias_find_local_alias_name?
      $site_name = $drupal_root . '#' . $drupal_uri;
    }
  }
  return $site_name;
}