Skip to content

Commit

Permalink
FEATURE: resource faker fileContent function
Browse files Browse the repository at this point in the history
  • Loading branch information
simstern committed Jan 4, 2023
1 parent a4eb328 commit fec63fd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Classes/Provider/ResourceFakerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}

0 comments on commit fec63fd

Please sign in to comment.