diff --git a/src/Concrete/Entity/OrmEntityExtended.php b/src/Concrete/Entity/OrmEntityExtended.php index ad17e72..25912bd 100644 --- a/src/Concrete/Entity/OrmEntityExtended.php +++ b/src/Concrete/Entity/OrmEntityExtended.php @@ -9,7 +9,7 @@ /** * @MappedSuperclass */ -class OrmEntityExtended extends OrmEntityBase +class OrmEntityExtended extends OrmEntityBase implements \Serializable { use CanLoad; @@ -90,6 +90,14 @@ public function getDeletedAt() return $this->deletedAt; } + /** + * {@inheritdoc} + */ + public function serialize() + { + return serialize($this->toArray()); + } + /** * @param DateTime $createdAt */ @@ -114,6 +122,26 @@ public function setDeletedAt($deletedAt) $this->deletedAt = $deletedAt; } + /** + * + * @return array Assoc array of all properties of the + * present instance. + */ + public function toArray() + { + return get_object_vars($this); + } + + /** + * {@inheritdoc} + */ + public function unserialize(string $data) + { + $arr = unserialize($data); + + $this->load($arr); + } + /** * Return whetever the safe delete functionality is activated or not. *