add getData method

This commit is contained in:
ghost 2024-02-03 11:05:47 +02:00
parent fbfaed02fc
commit b82a2de231
2 changed files with 24 additions and 0 deletions

View File

@ -174,6 +174,18 @@ var_dump (
);
```
#### Filesystem::getData
Return file content if path match storage item
```
var_dump (
$filesystem->getData(
'/full/path/to/page.txt'
)
);
```
### Helper
Useful methods to minify controller codebase

View File

@ -163,6 +163,18 @@ class Filesystem
return $path;
}
public function getData(string $path): ?string
{
if (isset($this->_list[$path]) && is_file($path) || is_readable($path))
{
return file_get_contents(
$path
);
}
return null;
}
private function _index(string $path, ?array $blacklist = ['.', '..', 'sidebar.txt', '__template.txt']): void
{
foreach ((array) scandir($path) as $file)