Skip to content

Commit

Permalink
Merge pull request #74 from ConductionNL/development
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
rjzondervan authored Nov 28, 2024
2 parents dd541e0 + 37761f1 commit f9be5aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/Service/ObjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ public function createFromArray(array $object) {
* @param bool $updatedObject Whether this is an update operation
* @return ObjectEntity The updated object
*/
public function updateFromArray(string $id, array $object, bool $updatedObject) {
public function updateFromArray(string $id, array $object, bool $updatedObject, bool $patch = false) {
// Add ID to object data for update
$object['id'] = $id;

return $this->saveObject(
// If we want the update to behave like patch, merge with existing object.
if ($patch === true) {
$oldObject = $this->getObject($this->registerMapper->find($this->getRegister()), $this->schemaMapper->find($this->getSchema()), $id)->jsonSerialize();

$object = array_merge($oldObject, $object);
}

return $this->saveObject(
register: $this->getRegister(),
schema: $this->getSchema(),
object: $object
Expand Down

0 comments on commit f9be5aa

Please sign in to comment.