You are here

function file_valid_uri in Drupal 8

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

Determines whether the URI has a valid scheme for file API operations.

There must be a scheme and it must be a Drupal-provided scheme like 'public', 'private', 'temporary', or an extension provided with hook_stream_wrappers().

Parameters

$uri: The URI to be tested.

Return value

TRUE if the URI is allowed.

Deprecated

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

See also

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

Related topics

1 call to file_valid_uri()
FileSystemDeprecationTest::testDeprecatedValidUri in core/tests/Drupal/KernelTests/Core/File/FileSystemDeprecationTest.php
@expectedDeprecation file_valid_uri() is deprecated in drupal:8.8.0 and will be removed before drupal:9.0.0. Use \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::isValidUri() instead. See https://www.drupal.org/node/3035273

File

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

Code

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