Skip to content

Commit

Permalink
#2 serialization of extended entities implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
1stthomas committed May 28, 2021
1 parent 8067884 commit 4c8c11d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/Concrete/Entity/OrmEntityExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @MappedSuperclass
*/
class OrmEntityExtended extends OrmEntityBase
class OrmEntityExtended extends OrmEntityBase implements \Serializable
{

use CanLoad;
Expand Down Expand Up @@ -90,6 +90,14 @@ public function getDeletedAt()
return $this->deletedAt;
}

/**
* {@inheritdoc}
*/
public function serialize()
{
return serialize($this->toArray());
}

/**
* @param DateTime $createdAt
*/
Expand All @@ -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.
*
Expand Down

0 comments on commit 4c8c11d

Please sign in to comment.