protected function doGenerateString(string
$uri, bool
$relative): string
{ // Allow the URI to be altered, e.g. to serve a file from a CDN or static
// file server.
$this->moduleHandler->
alter('file_url',
$uri);
$scheme = StreamWrapperManager::
getScheme($uri);
if (!
$scheme) { $baseUrl =
$relative ?
base_path() :
$this->requestStack->
getCurrentRequest()->
getSchemeAndHttpHost() .
base_path();
return $this->
generatePath($baseUrl,
$uri);
} elseif ($scheme == 'http' ||
$scheme == 'https' ||
$scheme == 'data'
) { // Check for HTTP and data URI-encoded URLs so that we don't have to
// implement getExternalUrl() for the HTTP and data schemes.
return $relative ?
$this->
transformRelative($uri) :
$uri;
} elseif ($wrapper =
$this->streamWrapperManager->
getViaUri($uri)) { // Attempt to return an external URL using the appropriate wrapper.
$externalUrl =
$wrapper->
getExternalUrl();
return $relative ?
$this->
transformRelative($externalUrl) :
$externalUrl;
}