Add function to check if object with given identifier exists
This commit is contained in:
parent
a75d91ff6d
commit
794e174748
@ -88,6 +88,32 @@ class JsonDatabase implements IJsonUnflattener
|
|||||||
return $retPath;
|
return $retPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exists(string $class, string $name, ?int $timestamp = null): 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 false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function load(string $class, string $name, ?int $timestamp = null): JsonSerializable|null
|
public function load(string $class, string $name, ?int $timestamp = null): JsonSerializable|null
|
||||||
{
|
{
|
||||||
if ($class == null || empty(trim($name)))
|
if ($class == null || empty(trim($name)))
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace SeriousJSON;
|
|
||||||
|
|
||||||
class JsonHistoryItem extends \SeriousJSON\JsonSerializable implements \SeriousJSON\IJsonIdentifiable {
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user