Guest User

Untitled

a guest
Apr 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7.  
  8. /**
  9. * @ORM\Table(name="users")
  10. * @ORM\Entity
  11. */
  12. class User implements UserInterface, \Serializable
  13. {
  14. /**
  15. * @ORM\Column(type="integer")
  16. * @ORM\Id
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. */
  19. private $id;
  20.  
  21. /**
  22. * @ORM\Column(type="string", length=25, unique=true)
  23. */
  24. private $username;
  25.  
  26. /**
  27. * @ORM\Column(type="string", length=64)
  28. */
  29. private $password;
  30.  
  31. /**
  32. * @ORM\Column(type="string", length=254, unique=true)
  33. */
  34. private $email;
  35.  
  36. /**
  37. * @ORM\Column(name="is_active", type="boolean")
  38. */
  39. private $isActive;
  40.  
  41. public function __construct()
  42. {
  43. $this->isActive = true;
  44. // may not be needed, see section on salt below
  45. // $this->salt = md5(uniqid('', true));
  46. }
  47.  
  48. public function setUsername($username)
  49. {
  50. $this->username = $username;
  51.  
  52. return $this;
  53. }
  54.  
  55. public function getUsername()
  56. {
  57. return $this->username;
  58. }
  59.  
  60. public function getSalt()
  61. {
  62. // you *may* need a real salt depending on your encoder
  63. // see section on salt below
  64. return null;
  65. }
  66.  
  67. public function setPassword($password)
  68. {
  69. $this->password = $password;
  70.  
  71. return $this;
  72. }
  73.  
  74. public function getPassword()
  75. {
  76. return $this->password;
  77. }
  78.  
  79. public function getRoles()
  80. {
  81. return array('ROLE_USER');
  82. }
  83.  
  84. public function eraseCredentials()
  85. {
  86. }
  87.  
  88. /** @see \Serializable::serialize() */
  89. public function serialize()
  90. {
  91. return serialize(array(
  92. $this->id,
  93. $this->username,
  94. $this->password,
  95. // see section on salt below
  96. // $this->salt,
  97. ));
  98. }
  99.  
  100. /** @see \Serializable::unserialize() */
  101. public function unserialize($serialized)
  102. {
  103. list (
  104. $this->id,
  105. $this->username,
  106. $this->password,
  107. // see section on salt below
  108. // $this->salt
  109. ) = unserialize($serialized);
  110. }
  111.  
  112. /**
  113. * @return mixed
  114. */
  115. public function getEmail()
  116. {
  117. return $this->email;
  118. }
  119.  
  120. /**
  121. * @param mixed $email
  122. *
  123. * @return User
  124. */
  125. public function setEmail($email)
  126. {
  127. $this->email = $email;
  128.  
  129. return $this;
  130. }
  131.  
  132. /**
  133. * @return mixed
  134. */
  135. public function getIsActive()
  136. {
  137. return $this->isActive;
  138. }
  139.  
  140. /**
  141. * @param mixed $isActive
  142. *
  143. * @return User
  144. */
  145. public function setIsActive($isActive)
  146. {
  147. $this->isActive = $isActive;
  148.  
  149. return $this;
  150. }
  151. }
Add Comment
Please, Sign In to add comment