You are here

static function RealisticDummyContentEnvironment::GetFileContents in Realistic Dummy Content 7

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/includes/RealisticDummyContentEnvironment.inc, line 409
Define RealisticDummyContentLiveEnvironment autoload class.

Class

RealisticDummyContentEnvironment
The abstract base environment.

Code

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