Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 344324b47a | |||
| fe87df07fe | |||
| 4c843c69c2 |
@@ -1,5 +1,9 @@
|
||||
# IQParts/Content
|
||||
|
||||
[](https://scrutinizer-ci.com/g/IQParts/content/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/IQParts/content/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/IQParts/content/build-status/master)
|
||||
|
||||
### Installation
|
||||
`composer require iqparts/content`
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ final class File extends Item
|
||||
* @var bool
|
||||
*/
|
||||
private $isEditable;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $content = null;
|
||||
|
||||
/**
|
||||
* PublicFile constructor.
|
||||
@@ -82,7 +86,19 @@ final class File extends Item
|
||||
$parent = substr($this->path, 0, $parentSep);
|
||||
} else $parent = '/';
|
||||
$this->parent = base64_encode($parent);
|
||||
$this->isEditable = $editable[$extension] ?? false;
|
||||
|
||||
$isEditable = $editable[$extension] ?? false;
|
||||
$content = false;
|
||||
if ($isEditable) {
|
||||
$content = $file->read();
|
||||
}
|
||||
|
||||
if ($isEditable && $content !== false) {
|
||||
$this->content = $content;
|
||||
$this->isEditable = true;
|
||||
} else {
|
||||
$this->isEditable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +187,7 @@ final class File extends Item
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
if ($this->content !== null) return $this->content;
|
||||
return $this->file->read();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user