Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a560fad40 | |||
| b14d0b40a7 | |||
| 344324b47a | |||
| fe87df07fe | |||
| 4c843c69c2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ tmp/
|
|||||||
.vs/
|
.vs/
|
||||||
.vscode/
|
.vscode/
|
||||||
coverage/
|
coverage/
|
||||||
|
.phpunit*
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
# IQParts/Content
|
# 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
|
### Installation
|
||||||
`composer require iqparts/content`
|
`composer require iqparts/content`
|
||||||
|
|
||||||
|
|||||||
@@ -10,21 +10,26 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": "^8.0",
|
||||||
"league/flysystem": "^1.0",
|
"league/flysystem": "^1.0",
|
||||||
"psr/http-message": "^1.0",
|
"psr/http-message": "^1.0",
|
||||||
"guzzlehttp/psr7": "^1.4"
|
"guzzlehttp/psr7": "^1.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7.0"
|
"phpunit/phpunit": "^9.5"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"IQParts\\Content\\": ["src"]
|
"IQParts\\Content\\": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"IQParts\\ContentTest\\": ["test"]
|
"IQParts\\ContentTest\\": [
|
||||||
|
"test"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ final class File extends Item
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $isEditable;
|
private $isEditable;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $content = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PublicFile constructor.
|
* PublicFile constructor.
|
||||||
@@ -82,7 +86,19 @@ final class File extends Item
|
|||||||
$parent = substr($this->path, 0, $parentSep);
|
$parent = substr($this->path, 0, $parentSep);
|
||||||
} else $parent = '/';
|
} else $parent = '/';
|
||||||
$this->parent = base64_encode($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()
|
public function getContents()
|
||||||
{
|
{
|
||||||
|
if ($this->content !== null) return $this->content;
|
||||||
return $this->file->read();
|
return $this->file->read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user