You are here

function file_stream_wrapper_uri_normalize in Drupal 8

Same name and namespace in other branches
  1. 7 includes/file.inc \file_stream_wrapper_uri_normalize()

Normalizes a URI by making it syntactically correct.

A stream is referenced as "scheme://target".

The following actions are taken:

  • Remove trailing slashes from target
  • Trim erroneous leading slashes from target. e.g. ":///" becomes "://".

Parameters

string $uri: String reference containing the URI to normalize.

Return value

string The normalized URI.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::normalizeUri() instead.

See also

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

Related topics

2 calls to file_stream_wrapper_uri_normalize()
FileSystemDeprecationTest::testDeprecatedFileStreamWrapperUriNormalize in core/tests/Drupal/KernelTests/Core/File/FileSystemDeprecationTest.php
@expectedDeprecation file_stream_wrapper_uri_normalize() is deprecated in drupal:8.8.0 and will be removed before drupal:9.0.0. Use \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::normalizeUri() instead. See https://www.drupal.org/node/3035273
file_unmanaged_prepare in core/includes/file.inc
Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.

File

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

Code

function file_stream_wrapper_uri_normalize($uri) {
  @trigger_error('file_stream_wrapper_uri_normalize() is deprecated in drupal:8.8.0 and will be removed before drupal:9.0.0. Use \\Drupal\\Core\\StreamWrapper\\StreamWrapperManagerInterface::normalizeUri() instead. See https://www.drupal.org/node/3035273', E_USER_DEPRECATED);
  return \Drupal::service('stream_wrapper_manager')
    ->normalizeUri($uri);
}