Advertisement
Guest User

Untitled

a guest
May 14th, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8.  
  9. /**
  10. * A user with an account (admin + traveler ftm).
  11. * @ApiResource
  12. * @ORM\Entity
  13. */
  14. class Account implements UserInterface, \Serializable
  15. {
  16. /**
  17. * @var int id
  18. *
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. * @ORM\Column(type="integer")
  22. */
  23. protected $id;
  24.  
  25. /**
  26. * @var string firstname
  27. *
  28. * @ORM\Column(type="text")
  29. */
  30. protected $firstname;
  31.  
  32. /**
  33. * @var string lastname
  34. *
  35. * @ORM\Column(type="text")
  36. */
  37. protected $lastname;
  38.  
  39. /**
  40. * @var string email
  41. *
  42. * @ORM\Column(type="text")
  43. */
  44. protected $email;
  45.  
  46. /**
  47. * @var string username
  48. *
  49. * @ORM\Column(type="text")
  50. */
  51. protected $username;
  52.  
  53. /**
  54. * @var string password
  55. *
  56. * @ORM\Column(type="text")
  57. */
  58. protected $password;
  59.  
  60. /**
  61. * @var string role
  62. *
  63. * @ORM\Column(type="text")
  64. */
  65. protected $role;
  66.  
  67. /**
  68. * @ORM\Column(name="is_active", type="boolean")
  69. */
  70. private $isActive;
  71.  
  72. public function __construct()
  73. {
  74. $this->isActive = true;
  75. // may not be needed, see section on salt below
  76. // $this->salt = md5(uniqid('', true));
  77. }
  78.  
  79.  
  80. public function getId(): ?int
  81. {
  82. return $this->id;
  83. }
  84.  
  85.  
  86. /**
  87. * Returns the username used to authenticate the user.
  88. *
  89. * @return string The username
  90. */
  91. public function getUsername()
  92. {
  93. return $this->username;
  94. }
  95.  
  96. /**
  97. * @return string
  98. */
  99. public function getFirstname(): string
  100. {
  101. return $this->firstname;
  102. }
  103.  
  104. /**
  105. * @param string $firstname
  106. */
  107. public function setFirstname(string $firstname): void
  108. {
  109. $this->firstname = $firstname;
  110. }
  111.  
  112. /**
  113. * @return string
  114. */
  115. public function getLastname(): string
  116. {
  117. return $this->lastname;
  118. }
  119.  
  120. /**
  121. * @param string $lastname
  122. */
  123. public function setLastname(string $lastname): void
  124. {
  125. $this->lastname = $lastname;
  126. }
  127.  
  128. /**
  129. * @return string
  130. */
  131. public function getEmail(): string
  132. {
  133. return $this->email;
  134. }
  135.  
  136. /**
  137. * @param string $email
  138. */
  139. public function setEmail(string $email): void
  140. {
  141. $this->email = $email;
  142. $this->username = $email;
  143. }
  144.  
  145. /**
  146. * @return string
  147. */
  148. public function getPassword(): string
  149. {
  150. return $this->password;
  151. }
  152.  
  153. public function getSalt()
  154. {
  155. // you *may* need a real salt depending on your encoder
  156. // see section on salt below
  157. return null;
  158. }
  159.  
  160. /**
  161. * @param string $password
  162. */
  163. public function setPassword(string $password): void
  164. {
  165. $this->password = $password;
  166. }
  167.  
  168. /**
  169. * @return string
  170. */
  171. public function getRoles(): string
  172. {
  173. return $this->role;
  174. }
  175.  
  176. /**
  177. * @param string $role
  178. */
  179. public function setRole(string $role): void
  180. {
  181. $this->role = $role;
  182. }
  183.  
  184. /** @see \Serializable::serialize() */
  185. public function serialize()
  186. {
  187. return serialize(array(
  188. $this->id,
  189. $this->email,
  190. $this->password,
  191. // see section on salt below
  192. // $this->salt,
  193. ));
  194. }
  195.  
  196. /** @see \Serializable::unserialize() */
  197. public function unserialize($serialized)
  198. {
  199. list (
  200. $this->id,
  201. $this->email,
  202. $this->password,
  203. // see section on salt below
  204. // $this->salt
  205. ) = unserialize($serialized);
  206. }
  207.  
  208. /**
  209. * Removes sensitive data from the user.
  210. *
  211. * This is important if, at any given point, sensitive information like
  212. * the plain-text password is stored on this object.
  213. */
  214. public function eraseCredentials()
  215. {
  216. // TODO: Implement eraseCredentials() method.
  217. }
  218.  
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement