Skip to content

Commit 1e0b3d6

Browse files
committed
bug #495 #494 Implements Serializable interface in the User entity (apetitpa)
This PR was squashed before being merged into the master branch (closes #495). Discussion ---------- #494 Implements Serializable interface in the User entity As discussed in #494, implements the `Serializable` interface in the `User` entity. Commits ------- 6ef90ad #494 Implements Serializable interface in the User entity
2 parents 4be656a + 6ef90ad commit 1e0b3d6

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/AppBundle/Entity/User.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @author Ryan Weaver <weaverryan@gmail.com>
2828
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
2929
*/
30-
class User implements UserInterface
30+
class User implements UserInterface, \Serializable
3131
{
3232
/**
3333
* @var int
@@ -190,4 +190,28 @@ public function eraseCredentials()
190190
// if you had a plainPassword property, you'd nullify it here
191191
// $this->plainPassword = null;
192192
}
193+
194+
/** @see \Serializable::serialize() */
195+
public function serialize()
196+
{
197+
return serialize([
198+
$this->id,
199+
$this->username,
200+
$this->password,
201+
// see section on salt below
202+
// $this->salt,
203+
]);
204+
}
205+
206+
/** @see \Serializable::unserialize() */
207+
public function unserialize($serialized)
208+
{
209+
list(
210+
$this->id,
211+
$this->username,
212+
$this->password,
213+
// see section on salt below
214+
// $this->salt
215+
) = unserialize($serialized);
216+
}
193217
}

0 commit comments

Comments
 (0)