Add history support to StoredObject entity

This commit adds a history saving feature to the StoredObject entity, which allows saving versions of the object's changes over time. This is achieved by implementing a saveHistory method that captures data attributes like filename, IV, key information, and type. The corresponding Automated tests were also created. Furthermore, adjustments were made to the StoredObject test to align with the new feature.
This commit is contained in:
2024-06-04 22:31:50 +02:00
parent 9f141468c7
commit ea1d4c48f2
4 changed files with 72 additions and 4 deletions

View File

@@ -354,4 +354,19 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
return $this;
}
public function saveHistory(): void
{
if ('' === $this->getFilename()) {
return;
}
$this->datas['history'][] = [
'filename' => $this->getFilename(),
'iv' => $this->getIv(),
'key_infos' => $this->getKeyInfos(),
'type' => $this->getType(),
'before' => (new \DateTimeImmutable('now'))->getTimestamp(),
];
}
}