diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index 8a23e5b0d3c..ca7186bc95e 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -368,7 +368,7 @@ The code below shows the implementation of the throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $class)); } - return $this->loadUserByUsername($user->getUsername()); + return $this->findOneById($user->getId()); } public function supportsClass($class) @@ -429,7 +429,7 @@ returns the list of related groups:: use Doctrine\Common\Collections\ArrayCollection; // ... - class User implements AdvancedUserInterface + class User implements AdvancedUserInterface, \Serializable { /** * @ORM\ManyToMany(targetEntity="Group", inversedBy="users") @@ -448,6 +448,26 @@ returns the list of related groups:: { return $this->groups->toArray(); } + + /** + * @see \Serializable::serialize() + */ + public function serialize() + { + return serialize(array( + $this->id, + )); + } + + /** + * @see \Serializable::unserialize() + */ + public function unserialize($serialized) + { + list ( + $this->id, + ) = unserialize($serialized); + } } The ``AcmeUserBundle:Group`` entity class defines three table fields (``id``,