Remove a metadata file if empty when saving
This commit is contained in:
parent
7d2ada5e86
commit
c82ed9dbf3
|
@ -65,11 +65,15 @@ public function isDirty(): bool
|
||||||
*/
|
*/
|
||||||
public function save(): bool
|
public function save(): bool
|
||||||
{
|
{
|
||||||
if (!$this->isDirty() || empty($this->content)) {
|
if (!$this->isDirty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->writeToDisk($this->content);
|
if (empty($this->content)) {
|
||||||
|
$this->disk->delete($this->filename);
|
||||||
|
} else {
|
||||||
|
$this->writeToDisk($this->content);
|
||||||
|
}
|
||||||
|
|
||||||
$this->originalContent = $this->content;
|
$this->originalContent = $this->content;
|
||||||
|
|
||||||
|
@ -94,10 +98,14 @@ public function set($key, $value, bool $respectDots = true)
|
||||||
/**
|
/**
|
||||||
* Set many values at once
|
* Set many values at once
|
||||||
*/
|
*/
|
||||||
public function setMany(array $array)
|
public function setMany(array $array, bool $replace = false)
|
||||||
{
|
{
|
||||||
foreach ($array as $key => $value) {
|
if (!$replace) {
|
||||||
$this->set($key, $value);
|
foreach ($array as $key => $value) {
|
||||||
|
$this->set($key, $value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->content = $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user