1 file.test public FileTestHelper::getFileByFilename($filename, $reset = FALSE)

Get a file from the database based on its filename.

Parameters

string $filename: A file filename, usually generated by $this->randomName().

bool $reset: (optional) Whether to reset the internal file_load() cache.

Return value

File: A file object matching $filename.

File

core/modules/file/tests/file.test, line 58
Tests for file.module.

Class

FileTestHelper
Provides methods specifically for testing File module's field handling.

Code

public function getFileByFilename($filename, $reset = FALSE) {
  $files = file_load_multiple(array(), array('filename' => $filename), $reset);
  // Load the first file returned from the database.
  $returned_file = reset($files);
  return $returned_file;
}