diff --git a/src/Database.php b/src/Database.php index 818816b..9729659 100644 --- a/src/Database.php +++ b/src/Database.php @@ -109,7 +109,14 @@ class Database if ($newRecord->hasContent() || Configuration::getInstance()->deletedRecords !== 'no') { $oldRecord->setContent($newRecord->getContent(), false); $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 { $this->entityManager->remove($oldRecord); } diff --git a/src/Entity/Set.php b/src/Entity/Set.php index 9355035..5e9a500 100644 --- a/src/Entity/Set.php +++ b/src/Entity/Set.php @@ -209,4 +209,14 @@ class Set extends Entity throw $exception; } } + + /** + * Get the set's string representation for comparison. + * + * @return string The set's unique spec + */ + public function __toString(): string + { + return $this->getSpec(); + } }