diff --git a/src/Eccube/Entity/Customer.php b/src/Eccube/Entity/Customer.php index 10d9d0480b6..8b53cc8da37 100644 --- a/src/Eccube/Entity/Customer.php +++ b/src/Eccube/Entity/Customer.php @@ -28,7 +28,7 @@ * @ORM\HasLifecycleCallbacks() * @ORM\Entity(repositoryClass="Eccube\Repository\CustomerRepository") */ - class Customer extends \Eccube\Entity\AbstractEntity implements UserInterface + class Customer extends \Eccube\Entity\AbstractEntity implements UserInterface, \Serializable { /** * @var int @@ -1148,5 +1148,42 @@ public function getPoint() { return $this->point; } + + /** + * String representation of object + * @link http://php.net/manual/en/serializable.serialize.php + * @return string the string representation of the object or null + * @since 5.1.0 + */ + public function serialize() + { + // see https://symfony.com/doc/2.7/security/entity_provider.html#create-your-user-entity + // CustomerRepository::loadUserByUsername() で Status をチェックしているため、ここでは不要 + return serialize([ + $this->id, + $this->email, + $this->password, + $this->salt, + ]); + } + + /** + * Constructs the object + * @link http://php.net/manual/en/serializable.unserialize.php + * @param string $serialized

+ * The string representation of the object. + *

+ * @return void + * @since 5.1.0 + */ + public function unserialize($serialized) + { + list ( + $this->id, + $this->email, + $this->password, + $this->salt, + ) = unserialize($serialized); + } } } diff --git a/src/Eccube/Entity/Member.php b/src/Eccube/Entity/Member.php index f972b6f1a99..6eeda760d6b 100644 --- a/src/Eccube/Entity/Member.php +++ b/src/Eccube/Entity/Member.php @@ -28,7 +28,7 @@ * @ORM\HasLifecycleCallbacks() * @ORM\Entity(repositoryClass="Eccube\Repository\MemberRepository") */ - class Member extends \Eccube\Entity\AbstractEntity implements UserInterface + class Member extends \Eccube\Entity\AbstractEntity implements UserInterface, \Serializable { public static function loadValidatorMetadata(ClassMetadata $metadata) { @@ -468,5 +468,42 @@ public function getCreator() { return $this->Creator; } + + /** + * String representation of object + * @link http://php.net/manual/en/serializable.serialize.php + * @return string the string representation of the object or null + * @since 5.1.0 + */ + public function serialize() + { + // see https://symfony.com/doc/2.7/security/entity_provider.html#create-your-user-entity + // MemberRepository::loadUserByUsername() で Work をチェックしているため、ここでは不要 + return serialize([ + $this->id, + $this->login_id, + $this->password, + $this->salt, + ]); + } + + /** + * Constructs the object + * @link http://php.net/manual/en/serializable.unserialize.php + * @param string $serialized

+ * The string representation of the object. + *

+ * @return void + * @since 5.1.0 + */ + public function unserialize($serialized) + { + list ( + $this->id, + $this->login_id, + $this->password, + $this->salt, + ) = unserialize($serialized); + } } }