Browse Source

add getData method

main
ghost 9 months ago
parent
commit
b82a2de231
  1. 12
      README.md
  2. 12
      src/Dokuwiki/Filesystem.php

12
README.md

@ -174,6 +174,18 @@ var_dump ( @@ -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

12
src/Dokuwiki/Filesystem.php

@ -163,6 +163,18 @@ class Filesystem @@ -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)

Loading…
Cancel
Save