I want to find out whether a physical file is managed by Drupal and if it is, then load it.
I'm having trouble with the documentation which keeps displaying "File not found" at crucial moments, but it seemed that this ought to work:
$query = \Drupal::entityQuery('file');
$query->condition('uri', $file_uri);
$entity_ids = $query->execute();
if (count($entity_ids) == 1) {
$file = \Drupal::entityLoad($entity_ids[0]);
}
However, I get this message:
PHP Fatal error: Call to undefined method Drupal::entityLoad()