選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

156 行
3.4KB

  1. <?php
  2. namespace Lc\AdminBundle\Model\User;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Lc\AdminBundle\IModel\EntityInterface;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. /**
  7. * @ORM\MappedSuperclass()
  8. */
  9. abstract class User implements EntityInterface, UserInterface
  10. {
  11. /**
  12. * @ORM\Column(type="string", length=180, unique=true)
  13. */
  14. protected $email;
  15. /**
  16. * @ORM\Column(type="json")
  17. */
  18. protected $roles = [];
  19. /**
  20. * @var string The hashed password
  21. * @ORM\Column(type="string")
  22. */
  23. protected $password;
  24. /**
  25. * @ORM\Column(type="string", length=255, nullable=true)
  26. */
  27. protected $lastname;
  28. /**
  29. * @ORM\Column(type="string", length=255, nullable=true)
  30. */
  31. protected $firstname;
  32. /**
  33. * @ORM\Column(type="boolean")
  34. */
  35. protected $isVerified = false;
  36. public function getEmail(): ?string
  37. {
  38. return $this->email;
  39. }
  40. public function setEmail(string $email): self
  41. {
  42. $this->email = $email;
  43. return $this;
  44. }
  45. /**
  46. * A visual identifier that represents this user.
  47. *
  48. * @see UserInterface
  49. */
  50. public function getUsername(): string
  51. {
  52. return (string)$this->email;
  53. }
  54. /**
  55. * @see UserInterface
  56. */
  57. public function getRoles(): array
  58. {
  59. $roles = $this->roles;
  60. // guarantee every user at least has ROLE_USER
  61. $roles[] = 'ROLE_USER';
  62. return array_unique($roles);
  63. }
  64. public function setRoles(array $roles): self
  65. {
  66. $this->roles = $roles;
  67. return $this;
  68. }
  69. /**
  70. * @see UserInterface
  71. */
  72. public function getPassword(): string
  73. {
  74. return (string)$this->password;
  75. }
  76. public function setPassword(string $password): self
  77. {
  78. $this->password = $password;
  79. return $this;
  80. }
  81. /**
  82. * @see UserIn
  83. */
  84. public function getSalt()
  85. {
  86. // not needed when using the "bcrypt" algorithm in security.yaml
  87. }
  88. /**
  89. * @see UserInterface
  90. */
  91. public function eraseCredentials()
  92. {
  93. // If you store any temporary, sensitive data on the user, clear it here
  94. // $this->plainPassword = null;
  95. }
  96. public function getLastname(): ?string
  97. {
  98. return $this->lastname;
  99. }
  100. public function setLastname(?string $lastname): self
  101. {
  102. $this->lastname = $lastname;
  103. return $this;
  104. }
  105. public function getFirstname(): ?string
  106. {
  107. return $this->firstname;
  108. }
  109. public function setFirstname(?string $firstname): self
  110. {
  111. $this->firstname = $firstname;
  112. return $this;
  113. }
  114. public function isVerified(): bool
  115. {
  116. return $this->isVerified;
  117. }
  118. public function setIsVerified(bool $isVerified): self
  119. {
  120. $this->isVerified = $isVerified;
  121. return $this;
  122. }
  123. }