You are here

public function RealisticDummyContentDummyEnvironment::fileSaveData in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/includes/RealisticDummyContentDummyEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentDummyEnvironment::fileSaveData()

Save the file data to the real or test environment.

Parameters

string $data: The data.

string $destination: Where to put it.

Return value

object The file object.

Throws

\Exception

Overrides RealisticDummyContentEnvironment::fileSaveData

File

api/src/includes/RealisticDummyContentDummyEnvironment.php, line 39

Class

RealisticDummyContentDummyEnvironment
The dummy environment.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public function fileSaveData($data, $destination = NULL) {
  if (!$destination) {
    throw new \Exception('the dummy file system is not designed to use null destination');
  }
  $parsed = parse_url($destination);
  $return_array = array(
    'fid' => 1,
    'uri' => $destination,
    'filename' => $parsed['host'],
  );
  return (object) $return_array;
}