You are here

function file_build_uri in Drupal 8

Same name and namespace in other branches
  1. 7 includes/file.inc \file_build_uri()
  2. 9 core/includes/file.inc \file_build_uri()

Constructs a URI to Drupal's default files location given a relative path.

Related topics

6 calls to file_build_uri()
file_unmanaged_copy in core/includes/file.inc
Copies a file to a new location without database changes or hook invocation.
file_unmanaged_move in core/includes/file.inc
Moves a file to a new location without database changes or hook invocation.
file_unmanaged_prepare in core/includes/file.inc
Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.
ImageStyle::buildUrl in core/modules/image/src/Entity/ImageStyle.php
Returns the URL of this image derivative for an original image path or URI.
StreamWrapperTest::testUriFunctions in core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
Test the getViaUri() and getViaScheme() methods and target functions.

... See full list

File

core/includes/file.inc, line 560
API for handling file uploads and server file management.

Code

function file_build_uri($path) {
  $uri = \Drupal::config('system.file')
    ->get('default_scheme') . '://' . $path;

  /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
  $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
  return $stream_wrapper_manager
    ->normalizeUri($uri);
}