DB: Pass callback to serializer

This commit is contained in:
root 2022-12-03 23:24:58 +01:00
parent 548a2376d4
commit 00eac092d0

View File

@ -202,7 +202,7 @@ class JsonDatabase implements IJsonUnflattener
return []; return [];
$serIdentifier = self::SanitizeIdentifier(strval($serIdentifier)); $serIdentifier = self::SanitizeIdentifier(strval($serIdentifier));
if (empty($serIdentifier) || empty($serClass)) if (empty($serIdentifier) || empty($serClass) || empty($findClass))
return []; return [];
$serPath = $this->getObjectPath($serClass, $serIdentifier) . self::$EXTENSION_INDEX; $serPath = $this->getObjectPath($serClass, $serIdentifier) . self::$EXTENSION_INDEX;
@ -220,8 +220,8 @@ class JsonDatabase implements IJsonUnflattener
return []; return [];
// TODO: Check if the referenced objects exist on disk // TODO: Check if the referenced objects exist on disk
if (array_key_exists(get_class($findClass), $indexJson)) if (array_key_exists($findClass, $indexJson))
return $indexJson[get_class($findClass)]; return $indexJson[$findClass];
else else
return []; return [];
} }
@ -245,7 +245,7 @@ class JsonDatabase implements IJsonUnflattener
if (strlen($objPath) > PHP_MAXPATHLEN) if (strlen($objPath) > PHP_MAXPATHLEN)
throw new Exception('JsonDatabase: Specified Path ' . $objPath . ' is longer than allowed.'); throw new Exception('JsonDatabase: Specified Path ' . $objPath . ' is longer than allowed.');
$objJson = $obj->Serialize(nested: $this->nested, to_array: false); $objJson = $obj->Serialize(nested: $this->nested, to_array: false, callback: $this);
if ($this->audit) if ($this->audit)
{ {