Skip to content

Commit 6ef90ad

Browse files
apetitpajaviereguiluz
authored andcommitted
#494 Implements Serializable interface in the User entity
1 parent 409a65b commit 6ef90ad

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
@@ -18,7 +18,7 @@
1818
* @author Ryan Weaver <[email protected]>
1919
* @author Javier Eguiluz <[email protected]>
2020
*/
21-
class User implements UserInterface
21+
class User implements UserInterface, \Serializable
2222
{
2323
/**
2424
* @var int
@@ -163,4 +163,28 @@ public function eraseCredentials()
163163
// if you had a plainPassword property, you'd nullify it here
164164
// $this->plainPassword = null;
165165
}
166+
167+
/** @see \Serializable::serialize() */
168+
public function serialize()
169+
{
170+
return serialize([
171+
$this->id,
172+
$this->username,
173+
$this->password,
174+
// see section on salt below
175+
// $this->salt,
176+
]);
177+
}
178+
179+
/** @see \Serializable::unserialize() */
180+
public function unserialize($serialized)
181+
{
182+
list(
183+
$this->id,
184+
$this->username,
185+
$this->password,
186+
// see section on salt below
187+
// $this->salt
188+
) = unserialize($serialized);
189+
}
166190
}

0 commit comments

Comments
 (0)