You are here

static function Environment::GetFileContents in Realistic Dummy Content 8

Returns the trimmed contents of a Drpual file object, or NULL if empty.

Parameters

$file: A drupal file object

Return value

NULL if no contents in file, or if an error occurred; otherwise a string with the trimmed contents of the file.

File

api/src/environments/Environment.php, line 406
Define autoload class.

Class

Environment
The abstract base environment.

Namespace

Drupal\realistic_dummy_content_api\environments

Code

static function GetFileContents($file) {
  try {
    if (!is_object($file)) {
      throw new Exception('Please use a file object');
    }
    return trim(self::Get()
      ->file_get_contents($file->uri));
  } catch (\Exception $e) {
    return NULL;
  }
}