Skip to content

Commit

Permalink
Merge pull request #76 from ConductionNL/fix/check-id-when-save-object
Browse files Browse the repository at this point in the history
Create new object if no id
  • Loading branch information
bbrands02 authored Nov 29, 2024
2 parents 37761f1 + e1f6434 commit 90f8c7a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Service/ObjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public function saveObject(int $register, int $schema, array $object): ObjectEnt
if (is_string($register)) {
$register = $this->registerMapper->find($register);
}

if (is_string($schema)) {
$schema = $this->schemaMapper->find($schema);
}
Expand All @@ -321,7 +322,7 @@ public function saveObject(int $register, int $schema, array $object): ObjectEnt
$validationResult = $this->validateObject(object: $object, schemaId: $schema);

// Create new entity if none exists
if ($objectEntity === null) {
if (isset($object['id']) === false || $objectEntity === null) {
$objectEntity = new ObjectEntity();
$objectEntity->setRegister($register);
$objectEntity->setSchema($schema);
Expand Down

0 comments on commit 90f8c7a

Please sign in to comment.