function drush_sitealias_local_site_path

8.0.x sitealias.inc drush_sitealias_local_site_path($alias_record)
6.x sitealias.inc drush_sitealias_local_site_path($alias_record)
7.x sitealias.inc drush_sitealias_local_site_path($alias_record)
3.x sitealias.inc drush_sitealias_local_site_path($alias_record)
4.x sitealias.inc drush_sitealias_local_site_path($alias_record)
5.x sitealias.inc drush_sitealias_local_site_path($alias_record)
master sitealias.inc drush_sitealias_local_site_path($alias_record)

Return the full path to the site directory of the given alias record.

Parameters

$alias_record: The alias record

Return value

The path to the site directory of the associated alias record, or NULL if the record is not a local site.

7 calls to drush_sitealias_local_site_path()
drush_core_pre_site_install in commands/core/site_install.drush.inc
Perform setup tasks for installation.
drush_sitealias_alias_path in includes/sitealias.inc
Return the array of paths where alias files are searched for.
drush_sitealias_cache_alias_by_path in includes/sitealias.inc
Cache the specified alias in the alias path cache. The alias path cache creates a lookup from the site folder (/path/to/drupal/sites/default) to the provided alias record.
drush_sitealias_get_record in includes/sitealias.inc
Get a site alias record given an alias name or site specification.
drush_sitealias_lookup_alias_by_path in includes/sitealias.inc
Look for a defined alias that points to the specified site directory. The cache is tested first; if nothing is cached, then an exhaustive search is done for the specified site. If the exhaustive search returns a match, then it is cached.

... See full list

File

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

Code

function drush_sitealias_local_site_path($alias_record) {
  $result = NULL;

  if (isset($alias_record['root']) && !isset($alias_record['remote-host'])) {
    if (isset($alias_record['uri'])) {
      $uri = $alias_record['uri'];
      $uri = preg_replace('#^[^:]*://#', '', $uri);
      while (!$result && !empty($uri)) {
        if (file_exists($alias_record['root'] . '/sites/sites.php')) {
          $sites = array();
          include ($alias_record['root'] . '/sites/sites.php');
          if (array_key_exists($uri, $sites)) {
            $result = $alias_record['root'] . '/sites/' . $sites[$uri];
          }
        }
        if (!$result) {
          $result = ($alias_record['root'] . '/sites/' . drush_sitealias_uri_to_site_dir($uri, drush_sitealias_get_root($alias_record)));
        }
        $result = realpath($result);
        $uri = preg_replace('#^[^.]*\.*#', '', $uri);
      }
    }
    if (!$result) {
      $result = realpath($alias_record['root'] . '/sites/default');
    }
  }

  return $result;
}