diff --git a/php/Job/Entity/Create.php b/php/Job/Entity/Create.php index f897624..8fad6ca 100644 --- a/php/Job/Entity/Create.php +++ b/php/Job/Entity/Create.php @@ -46,6 +46,19 @@ public function run(Converter $converter): array $type = $space->getProperty($k)['type']; if ($type === 'uuid') { $v = new Uuid($v); + } elseif ($type == 'map') { + if ($v !== null) { + if (is_string($v)) { + $v = json_decode($v); + } + if (!is_array($v) && !is_object($v)) { + throw new Exception("Invalid type for '$k' ($type): $values[$k]"); + } + $v = $converter->toArray($v); + if (!count($v)) { + $v = null; + } + } } elseif (is_object($v)) { $v = $converter->toArray($v); } diff --git a/php/Job/Entity/Update.php b/php/Job/Entity/Update.php index 465b3cc..32ca252 100644 --- a/php/Job/Entity/Update.php +++ b/php/Job/Entity/Update.php @@ -61,8 +61,23 @@ public function run(Converter $converter): void $type = $space->getProperty($k)['type']; if ($type === 'uuid') { $v = new Uuid($v); - } elseif (is_object($v)) { - $v = $converter->toArray($v); + } elseif ($type == 'map') { + if ($v !== null) { + if (is_string($v)) { + $v = json_decode($v); + } + if (!is_array($v) && !is_object($v)) { + $extra = ''; + if (is_string($this->values->$k)) { + $extra .= ': ' . $this->values->$k; + } + throw new Exception("Invalid type for '$k' ($type)$extra"); + } + $v = $converter->toArray($v); + if (!count($v)) { + $v = null; + } + } } $entity->$k = $v; }