function google_appliance_locate_root in Google Search Appliance 7
Same name and namespace in other branches
- 8 src/Service/Click.php \google_appliance_locate_root()
Exhaustive depth-first search to try and locate the Drupal root directory.
Parameters
$start_path: Search start path. Defaults to current working directory.
Return value
A path to Drupal root, or FALSE if not found.
See also
drush_locate_root()
1 call to google_appliance_locate_root()
- google_appliance.callback.click.php in ./
google_appliance.callback.click.php - The callback for the Google Appliance module's /click service.
File
- ./
google_appliance.callback.click.php, line 58 - The callback for the Google Appliance module's /click service.
Code
function google_appliance_locate_root($start_path = NULL) {
$drupal_root = FALSE;
if (empty($start_path)) {
$parts = parse_url($_SERVER['REQUEST_URI']);
$start_path = $_SERVER['DOCUMENT_ROOT'] . $parts['path'];
}
foreach (array(
TRUE,
FALSE,
) as $follow_symlinks) {
$path = $start_path;
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
// Check the start path.
if (google_appliance_valid_drupal_root($path)) {
$drupal_root = $path;
break;
}
else {
// Move up dir by dir and check each.
while ($path = _google_appliance_shift_path_up($path)) {
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
if (google_appliance_valid_drupal_root($path)) {
$drupal_root = $path;
break 2;
}
}
}
}
return $drupal_root;
}