file_load

file_load($fid, $reset = FALSE)

Loads a single file entity from the database.

Parameters

int $fid: A file ID.

bool $reset: (optional) Whether to reset the internal file_load_multiple() cache. Defaults to FALSE.

Return value

\Drupal\file\FileInterface|null A file entity or NULL if the file was not found.

Deprecated

in Drupal 8.x, will be removed before Drupal 9.0. Use \Drupal\file\Entity\File::load().

See also

hook_ENTITY_TYPE_load()

file_load_multiple()

File

core/modules/file/file.module, line 97
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_load($fid, $reset = FALSE) {
  if ($reset) {
    \Drupal::entityManager()->getStorage('file')->resetCache(array($fid));
  }
  return File::load($fid);
}
doc_Drupal
2016-10-29 09:14:12
Comments
Leave a Comment

Please login to continue.