protected static function UrlBag::toAbsolute in Mini site 8
Convert current URL to absolute.
Parameters
string $url: URL to convert.
string $base_url: The base site URL.
Return value
string Absolute URL.
3 calls to UrlBag::toAbsolute()
- UrlBag::getAliasAbsolute in src/
UrlBag.php - Get absolute alias path.
- UrlBag::getParentAliasAbsolute in src/
UrlBag.php - Get parent alias as an absolute URL.
- UrlBag::getUrlAbsolute in src/
UrlBag.php - Get URL as an absolute path.
File
- src/
UrlBag.php, line 266
Class
- UrlBag
- Class UrlBag.
Namespace
Drupal\minisiteCode
protected static function toAbsolute($url, $base_url) {
if (UrlHelper::isExternal($url)) {
return $url;
}
// Parsing URL with Core's parser to handle relative paths.
$parsed = UrlHelper::parse($url);
// Re-parsing the 'path' component again to extract actual path.
$parsed = isset($parsed['path']) ? parse_url($parsed['path']) : $parsed;
// Check that this is a file starting with a register wrapper scheme and
// return the URL as-is.
if (!empty($parsed['scheme'])) {
if (in_array($parsed['scheme'], static::getLocalWrapperSchemas())) {
// Files never get their URLs aliased, so return as-is.
return file_create_url($url);
}
}
return rtrim($base_url, '/') . '/' . ltrim($url, '/');
}