protected function FileDownloadUrl::fileCreateRootRelativeUrl in JSON:API 8
Creates a relative URL out of a URI.
This is a wrapper to the procedural code for testing purposes. For obvious reasons this method will not be unit tested, but that is fine since it's only using already tested Drupal API functions.
Parameters
string $uri: The URI to transform.
Return value
string The transformed relative URL.
1 call to FileDownloadUrl::fileCreateRootRelativeUrl()
- FileDownloadUrl::computeValue in src/
Field/ FileDownloadUrl.php - Initialize the internal field list with the modified items.
File
- src/
Field/ FileDownloadUrl.php, line 32
Class
- FileDownloadUrl
- Extends core URL field functionality.
Namespace
Drupal\jsonapi\FieldCode
protected function fileCreateRootRelativeUrl($uri) {
$wrapper = \Drupal::service('stream_wrapper_manager')
->getViaUri($uri);
if ($wrapper && $wrapper
->getType() & StreamWrapperInterface::VISIBLE) {
return file_url_transform_relative(file_create_url($uri));
}
// For testing purposes, return the $uri when the scheme is not a wrapper or
// not visible.
return $uri;
}