diff --git a/README.md b/README.md index 39a4a2a..4d5bea5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Dokuwiki/Filesystem.php b/src/Dokuwiki/Filesystem.php index 03aa337..8f91d04 100644 --- a/src/Dokuwiki/Filesystem.php +++ b/src/Dokuwiki/Filesystem.php @@ -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)