3 // src/Rapsys/UserBundle/Entity/User.php
4 namespace Rapsys\UserBundle\Entity
;
6 use Rapsys\UserBundle\Entity\Group
;
7 use Symfony\Component\Security\Core\User\UserInterface
;
8 use Doctrine\Common\Collections\ArrayCollection
;
10 class User
implements UserInterface
, \Serializable
{
57 * @var \Rapsys\UserBundle\Entity\Title
62 * @var \Doctrine\Common\Collections\Collection
69 public function __construct() {
70 $this->active
= false;
71 $this->groups
= new ArrayCollection();
79 public function getId() {
90 public function setMail($mail) {
101 public function getMail() {
108 * @param string $pseudonym
112 public function setPseudonym($pseudonym) {
113 $this->pseudonym
= $pseudonym;
123 public function getPseudonym() {
124 return $this->pseudonym
;
130 * @param string $forename
134 public function setForename($forename) {
135 $this->forename
= $forename;
145 public function getForename() {
146 return $this->forename
;
152 * @param string $surname
156 public function setSurname($surname) {
157 $this->surname
= $surname;
167 public function getSurname() {
168 return $this->surname
;
174 * @param string $password
178 public function setPassword($password) {
179 $this->password
= $password;
189 public function getPassword() {
190 return $this->password
;
196 * @param bool $active
200 public function setActive($active) {
201 $this->active
= $active;
211 public function getActive() {
212 return $this->active
;
218 * @param \DateTime $created
222 public function setCreated($created) {
223 $this->created
= $created;
233 public function getCreated() {
234 return $this->created
;
240 * @param \DateTime $updated
244 public function setUpdated($updated) {
245 $this->updated
= $updated;
255 public function getUpdated() {
256 return $this->updated
;
262 public function setTitle($title) {
263 $this->title
= $title;
271 public function getTitle() {
278 * @param \Rapsys\UserBundle\Entity\Group $group
282 public function addGroup(Group
$group) {
283 $this->groups
[] = $group;
291 * @param \Rapsys\UserBundle\Entity\Group $group
293 public function removeGroup(Group
$group) {
294 $this->groups
->removeElement($group);
300 * @return \Doctrine\Common\Collections\Collection
302 public function getGroups() {
303 return $this->groups
;
306 public function getRoles() {
307 $roles = [ 'ROLE_USER' ];
309 foreach($this->groups
->toArray() as $group) {
310 $roles[] = $group->getRole();
313 return array_unique($roles);
316 public function getSalt() {
317 //No salt required with bcrypt
321 public function getUsername() {
325 public function eraseCredentials() {
328 public function serialize() {
329 return serialize(array(
339 public function unserialize($serialized) {
347 ) = unserialize($serialized);
350 //XXX: was from vendor/symfony/security-core/User/AdvancedUserInterface.php, see if it's used anymore
351 public function isEnabled() {
352 return $this->active
;