Browse Source

add getMimeByPath method

main
ghost 10 months ago
parent
commit
82085aa8c3
  1. 12
      README.md
  2. 12
      src/Dokuwiki/Filesystem.php

12
README.md

@ -186,6 +186,18 @@ var_dump ( @@ -186,6 +186,18 @@ var_dump (
);
```
#### Filesystem::getMimeByPath
Return file MIME if path match storage item
```
var_dump (
$filesystem->getMimeByPath(
'/full/path/to/page.txt'
)
);
```
#### Filesystem::getDataByPath
Return file content if path match storage item

12
src/Dokuwiki/Filesystem.php

@ -187,6 +187,18 @@ class Filesystem @@ -187,6 +187,18 @@ class Filesystem
return $path;
}
public function getMimeByPath(?string $path): ?string
{
if (in_array($path, $this->_list) && is_file($path) || is_readable($path))
{
return mime_content_type(
$path
);
}
return null;
}
public function getDataByPath(?string $path): ?string
{
if (in_array($path, $this->_list) && is_file($path) || is_readable($path))

Loading…
Cancel
Save