Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a560fad40 | |||
| b14d0b40a7 | |||
| 344324b47a | |||
| fe87df07fe | |||
| 4c843c69c2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ tmp/
|
||||
.vs/
|
||||
.vscode/
|
||||
coverage/
|
||||
.phpunit*
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -10,21 +10,26 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"league/flysystem": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"IQParts\\Content\\": ["src"]
|
||||
"IQParts\\Content\\": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"IQParts\\ContentTest\\": ["test"]
|
||||
"IQParts\\ContentTest\\": [
|
||||
"test"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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