function drush_site_dir_lookup_from_hostname

8.0.x environment.inc drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL)
6.x environment.inc drush_site_dir_lookup_from_hostname($hostname)
7.x environment.inc drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL)
master environment.inc drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL)

Lookup a site's directory via the sites.php file given a hostname.

Parameters

$hostname: The hostname of a site. May be converted from URI.

Return value

$dir The directory associated with that hostname or FALSE if not found.

1 call to drush_site_dir_lookup_from_hostname()
drush_sitealias_uri_to_site_dir in includes/sitealias.inc
Convert from a URI to a site directory.

File

includes/environment.inc, line 237
Functions used by drush to query the environment and setting the current configuration.

Code

function drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL) {
  if (!isset($site_root)) {
    $site_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
  }
  if (!empty($site_root) && file_exists($site_root . '/sites/sites.php')) {
    $sites = array();
    // This will overwrite $sites with the desired mappings.
    include ($site_root . '/sites/sites.php');
    return isset($sites[$hostname]) ? $sites[$hostname] : FALSE;
  }
  else {
    return FALSE;
  }
}