protected function UiHelperTrait::getAbsoluteUrl in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::getAbsoluteUrl()
- 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::getAbsoluteUrl()
Takes a path and returns an absolute path.
Parameters
string $path: A path from the Mink controlled browser content.
Return value
string The $path with $base_url prepended, if necessary.
2 calls to UiHelperTrait::getAbsoluteUrl()
- ConvertTest::testConvertFileInRoot in core/
modules/ image/ tests/ src/ Functional/ ImageEffect/ ConvertTest.php - Tests that files stored in the root folder are converted properly.
- EntityReferenceAdminTest::testFieldAdminHandler in core/
modules/ field/ tests/ src/ Functional/ EntityReference/ EntityReferenceAdminTest.php - Tests the Entity Reference Admin UI.
File
- core/
tests/ Drupal/ Tests/ UiHelperTrait.php, line 312
Class
- UiHelperTrait
- Provides UI helper methods.
Namespace
Drupal\TestsCode
protected function getAbsoluteUrl($path) {
global $base_url, $base_path;
$parts = parse_url($path);
if (empty($parts['host'])) {
// Ensure that we have a string (and no xpath object).
$path = (string) $path;
// Strip $base_path, if existent.
$length = strlen($base_path);
if (substr($path, 0, $length) === $base_path) {
$path = substr($path, $length);
}
// Ensure that we have an absolute path.
if (empty($path) || $path[0] !== '/') {
$path = '/' . $path;
}
// Finally, prepend the $base_url.
$path = $base_url . $path;
}
return $path;
}