From 8df24f5550011e18464a91114adedfbc71c6c6ef Mon Sep 17 00:00:00 2001 From: Bredillet Thomas Date: Thu, 3 May 2018 08:40:53 +0200 Subject: [PATCH 1/2] Add mandatory method and attribut Without $roles, construct(), getRoles() and eraseCredentials(), this entity doesn't work because of his interface It may be nice to add these methods so that you do not have any errors when you copy paste --- doctrine/registration_form.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doctrine/registration_form.rst b/doctrine/registration_form.rst index 2f38d1eadcd..a43278eafb3 100644 --- a/doctrine/registration_form.rst +++ b/doctrine/registration_form.rst @@ -87,6 +87,15 @@ With some validation added, your class may look something like this:: * @ORM\Column(type="string", length=64) */ private $password; + + /** + * @ORM\Column(type="array") + */ + private $roles; + + public function __construct() { + $this->roles = array('ROLE_USER'); + } // other properties and methods @@ -136,6 +145,15 @@ With some validation added, your class may look something like this:: // You *may* need a real salt if you choose a different encoder. return null; } + + public function getRoles() + { + return $this->roles; + } + + public function eraseCredentials() + { + } // other methods, including security methods like getRoles() } From 23ad9642e68fa0b42cb6ab6ec4637b02b606e7ee Mon Sep 17 00:00:00 2001 From: Bredillet Thomas Date: Thu, 3 May 2018 11:33:09 +0200 Subject: [PATCH 2/2] Deleting an unused comment --- doctrine/registration_form.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doctrine/registration_form.rst b/doctrine/registration_form.rst index a43278eafb3..236928ffe1b 100644 --- a/doctrine/registration_form.rst +++ b/doctrine/registration_form.rst @@ -154,8 +154,6 @@ With some validation added, your class may look something like this:: public function eraseCredentials() { } - - // other methods, including security methods like getRoles() } The :class:`Symfony\\Component\\Security\\Core\\User\\UserInterface` requires