diff --git a/Classes/Provider/ResourceFakerProvider.php b/Classes/Provider/ResourceFakerProvider.php index 1e83900..d26cbee 100644 --- a/Classes/Provider/ResourceFakerProvider.php +++ b/Classes/Provider/ResourceFakerProvider.php @@ -39,8 +39,12 @@ public function setOptions(array $options): void */ public function persistentResource(string $fileName): ?PersistentResource { + if (substr($fileName, 0, 11) !== 'resource://') { + $fileName = $this->options['fixturePath'] . $fileName; + } + if ($this->options['persistenceEnabled'] === true) { - return $this->resourceManager->importResource($this->options['fixturePath'] . $fileName); + return $this->resourceManager->importResource($fileName); } else { return null; } @@ -81,4 +85,17 @@ public function persistentResourceImage(string $fileName): ?Image return null; } + + /** + * Content string from a resource. + * + * @param string $fileName + * @return string|null + */ + public function fileContent(string $fileName): ?string + { + $value = file_get_contents($fileName); + + return is_string($value) ? $value : null; + } }