You are here

function file_build_uri in Drupal 9

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

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

Deprecated

in drupal:9.3.0 and is removed from drupal:10.0.0 without replacement.

See also

https://www.drupal.org/node/3223091

Related topics

1 call to file_build_uri()
FileSystemDeprecationTest::testDeprecatedFileBuildUri in core/tests/Drupal/KernelTests/Core/File/FileSystemDeprecationTest.php
Tests deprecated file_build_uri()

File

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

Code

function file_build_uri($path) {
  @trigger_error('file_build_uri() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0 without replacement. See https://www.drupal.org/node/3223091', E_USER_DEPRECATED);
  $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);
}