Skip to content

Commit

Permalink
bug #495 #494 Implements Serializable interface in the User entity (a…
Browse files Browse the repository at this point in the history
…petitpa)

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
  • Loading branch information
javiereguiluz committed Apr 16, 2017
2 parents 4be656a + 6ef90ad commit 1e0b3d6
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/AppBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author Ryan Weaver <[email protected]>
* @author Javier Eguiluz <[email protected]>
*/
class User implements UserInterface
class User implements UserInterface, \Serializable
{
/**
* @var int
Expand Down Expand Up @@ -190,4 +190,28 @@ public function eraseCredentials()
// if you had a plainPassword property, you'd nullify it here
// $this->plainPassword = null;
}

/** @see \Serializable::serialize() */
public function serialize()
{
return serialize([
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
]);
}

/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list(
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
}

0 comments on commit 1e0b3d6

Please sign in to comment.