function google_appliance_locate_root in Google Search Appliance 8
Same name and namespace in other branches
- 7 google_appliance.callback.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()
File
- src/
Service/ Click.php, line 75 - Created by PhpStorm. User: mhavelant Date: 2017.05.23. Time: 18:01.
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 ([
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;
}