function drush_sitealias_uri_to_site_dir

8.0.x sitealias.inc drush_sitealias_uri_to_site_dir($uri, $site_root = NULL)
6.x sitealias.inc drush_sitealias_uri_to_site_dir($uri)
7.x sitealias.inc drush_sitealias_uri_to_site_dir($uri, $site_root = NULL)
3.x sitealias.inc drush_sitealias_uri_to_site_dir($uri)
4.x sitealias.inc drush_sitealias_uri_to_site_dir($uri)
5.x sitealias.inc drush_sitealias_uri_to_site_dir($uri)
master sitealias.inc drush_sitealias_uri_to_site_dir($uri, $site_root = NULL)

Convert from a URI to a site directory.

Parameters

uri: A uri, such as http://domain.com:8080/drupal

Return value

string A directory, such as domain.com.8080.drupal

8 calls to drush_sitealias_uri_to_site_dir()
drush_sitealias_alias_path in includes/sitealias.inc
Return the array of paths where alias files are searched for.
drush_sitealias_alias_record_to_spec in includes/sitealias.inc
Convert from an alias record to a site specification
drush_sitealias_get_record in includes/sitealias.inc
Get a site alias record given an alias name or site specification.
drush_sitealias_local_site_path in includes/sitealias.inc
Return the full path to the site directory of the given alias record.
_drush_sitealias_add_transient_defaults in includes/sitealias.inc
Add "transient" default values to the given alias record. The difference between a static default and a transient default is that static defaults -always- exist in the alias record, whereas transient defaults are only added if the given…

... See full list

File

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

Code

function drush_sitealias_uri_to_site_dir($uri, $site_root = NULL) {
  $uri = str_replace('http://', '', $uri);
  if (drush_is_windows()) {
    // Handle absolute paths on windows
    $uri = str_replace(array(':/', ':\\'), array('.', '.'), $uri);
  }

  $hostname = str_replace(array('/', ':', '\\'), array('.', '.', '.'), $uri);

  // Check sites.php mappings
  $site_dir = drush_site_dir_lookup_from_hostname($hostname, $site_root);

  return $site_dir ? $site_dir : $hostname;
}