Implement object deletion
This commit is contained in:
parent
794e174748
commit
f1fc105f49
@ -189,6 +189,37 @@ class JsonDatabase implements IJsonUnflattener
|
|||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(string $className, $identifier): bool
|
||||||
|
{
|
||||||
|
if ($class == null || empty(trim($name)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ($name != null && !empty(trim(strval($name))))
|
||||||
|
$name = JSONDatabase::SanitizeIdentifier($name);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$class = trim($class);
|
||||||
|
|
||||||
|
if (!$this->audit && $timestamp != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$objPath = $this->getObjectPath($class, $name, ($timestamp != null));
|
||||||
|
|
||||||
|
if (strlen($objPath) > PHP_MAXPATHLEN)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!is_file($objPath))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return unlink($objPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(IJsonIdentifiable $obj): bool
|
||||||
|
{
|
||||||
|
return $this->delete(get_class($obj), $obj->flatIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore a JsonSerializable from the Database by using it's Identifier reference.
|
* Restore a JsonSerializable from the Database by using it's Identifier reference.
|
||||||
* @param string $className the full class name with domain of the JsonSerializable property
|
* @param string $className the full class name with domain of the JsonSerializable property
|
||||||
|
Loading…
Reference in New Issue
Block a user