Add full support for sets

This commit is contained in:
Sebastian Meyer 2024-01-12 07:32:47 +01:00
parent c2f3e7493e
commit 6c700c6f24
2 changed files with 18 additions and 1 deletions

View File

@ -109,7 +109,14 @@ class Database
if ($newRecord->hasContent() || Configuration::getInstance()->deletedRecords !== 'no') { if ($newRecord->hasContent() || Configuration::getInstance()->deletedRecords !== 'no') {
$oldRecord->setContent($newRecord->getContent(), false); $oldRecord->setContent($newRecord->getContent(), false);
$oldRecord->setLastChanged($newRecord->getLastChanged()); $oldRecord->setLastChanged($newRecord->getLastChanged());
// TODO: Add full set support. // Add new sets.
foreach (array_diff($newRecord->getSets(), $oldRecord->getSets()) as $newSet) {
$oldRecord->addSet($newSet);
}
// Remove old sets.
foreach (array_diff($oldRecord->getSets(), $newRecord->getSets()) as $oldSet) {
$oldRecord->removeSet($oldSet);
}
} else { } else {
$this->entityManager->remove($oldRecord); $this->entityManager->remove($oldRecord);
} }

View File

@ -209,4 +209,14 @@ class Set extends Entity
throw $exception; throw $exception;
} }
} }
/**
* Get the set's string representation for comparison.
*
* @return string The set's unique spec
*/
public function __toString(): string
{
return $this->getSpec();
}
} }