Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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