RealisticDummyContentDummyEnvironment.php in Realistic Dummy Content 8.2
File
api/src/includes/RealisticDummyContentDummyEnvironment.php
View source
<?php
namespace Drupal\realistic_dummy_content_api\includes;
class RealisticDummyContentDummyEnvironment extends RealisticDummyContentEnvironment {
private $files;
public function createFile($path, $data) {
if (!is_array($this->files)) {
$this->files = array();
}
$this->files[$path] = $data;
}
public function fileGetContents($filename) {
if (isset($this->files[$filename])) {
return $this->files[$filename];
}
trigger_error('file_get_contents(): failed to open stream');
return NULL;
}
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;
}
public function fileSave(stdClass $file) {
}
}