function FileUploadHandler::loadByUri

Same name in other branches
  1. 9 core/modules/file/src/Upload/FileUploadHandler.php \Drupal\file\Upload\FileUploadHandler::loadByUri()

Loads the first File entity found with the specified URI.

Parameters

string $uri: The file URI.

Return value

\Drupal\file\FileInterface|null The first file with the matched URI if found, NULL otherwise.

Deprecated

in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\file\FileRepositoryInterface::loadByUri().

See also

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

File

core/modules/file/src/Upload/FileUploadHandler.php, line 468

Class

FileUploadHandler
Handles validating and creating file entities from file uploads.

Namespace

Drupal\file\Upload

Code

protected function loadByUri(string $uri) : ?FileInterface {
    @trigger_error('FileUploadHandler::loadByUri() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \\Drupal\\file\\FileRepositoryInterface::loadByUri(). See https://www.drupal.org/node/3409326', E_USER_DEPRECATED);
    return $this->fileRepository
        ->loadByUri($uri);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.