src/Entity/User.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use phpDocumentor\Reflection\Types\Boolean;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11. * @ORM\Entity(repositoryClass=UserRepository::class)
  12. * @ORM\Table(name="`user`")
  13. */
  14. class User implements UserInterface, PasswordAuthenticatedUserInterface
  15. {
  16. /**
  17. * @ORM\Id
  18. * @ORM\GeneratedValue
  19. * @ORM\Column(type="integer")
  20. */
  21. private ?int $id;
  22. /**
  23. * @ORM\Column(type="string", length=180, unique=true)
  24. */
  25. private string $username;
  26. /**
  27. * @ORM\Column(type="json")
  28. */
  29. private array $roles = [];
  30. /**
  31. * @var string The hashed password
  32. * @ORM\Column(type="string")
  33. */
  34. private string $password;
  35. /**
  36. * @ORM\Column(type="boolean")
  37. */
  38. private ?bool $lockMenu;
  39. /**
  40. * @ORM\Column(type="string", length=255)
  41. */
  42. private ?string $firstname;
  43. /**
  44. * @ORM\Column(type="string", length=255)
  45. */
  46. private ?string $lastname;
  47. /**
  48. * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="users")
  49. */
  50. private ?Category $category;
  51. /**
  52. * @ORM\Column(type="boolean")
  53. */
  54. private ?bool $styleButton;
  55. /**
  56. * @ORM\Column(type="boolean")
  57. */
  58. private $firstConnexion;
  59. /**
  60. * @ORM\Column(type="boolean")
  61. */
  62. private $dark;
  63. /**
  64. * @ORM\Column(type="boolean")
  65. */
  66. private $enable = 1;
  67. /**
  68. * @ORM\Column(type="boolean")
  69. */
  70. private ?bool $displayMyIntervention;
  71. /**
  72. * @ORM\Column(type="integer")
  73. */
  74. private $numberElementPerPage;
  75. /**
  76. * @ORM\Column(type="string", length=255)
  77. */
  78. private $initials;
  79. /**
  80. * @ORM\ManyToMany(targetEntity=Intervention::class, inversedBy="users")
  81. */
  82. private $interventionFav;
  83. /**
  84. * @ORM\Column(type="datetime", nullable=true)
  85. */
  86. private ?\DateTimeInterface $lastStartImportDate;
  87. /**
  88. * @ORM\Column(type="datetime", nullable=true)
  89. */
  90. private ?\DateTimeInterface $lastEndImportDate;
  91. public function getId(): ?int
  92. {
  93. return $this->id;
  94. }
  95. public function __construct(){
  96. $this->lockMenu = 1;
  97. $this->styleButton = 1;
  98. $this->dark = 0;
  99. $this->numberElementPerPage = 10;
  100. $this->firstConnexion = 1;
  101. $this->displayMyIntervention = 0;
  102. $this->interventionFav = new ArrayCollection();
  103. }
  104. public function __toString(): string
  105. {
  106. return $this->firstname . ' ' . $this->lastname;
  107. }
  108. /**
  109. * @deprecated since Symfony 5.3, use getUserIdentifier instead
  110. */
  111. public function getUsername(): string
  112. {
  113. return (string) $this->username;
  114. }
  115. public function setUsername(string $username): self
  116. {
  117. $this->username = $username;
  118. return $this;
  119. }
  120. /**
  121. * A visual identifier that represents this user.
  122. *
  123. * @see UserInterface
  124. */
  125. public function getUserIdentifier(): string
  126. {
  127. return (string) $this->username;
  128. }
  129. /**
  130. * @see UserInterface
  131. */
  132. public function getRoles(): array
  133. {
  134. $roles = $this->roles;
  135. // guarantee every user at least has ROLE_USER
  136. $roles[] = 'ROLE_USER';
  137. return array_unique($roles);
  138. }
  139. public function setRoles(array $roles): self
  140. {
  141. $this->roles = $roles;
  142. return $this;
  143. }
  144. /**
  145. * @see PasswordAuthenticatedUserInterface
  146. */
  147. public function getPassword(): string
  148. {
  149. return $this->password;
  150. }
  151. public function setPassword(string $password): self
  152. {
  153. $this->password = $password;
  154. return $this;
  155. }
  156. /**
  157. * Returning a salt is only needed, if you are not using a modern
  158. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  159. *
  160. * @see UserInterface
  161. */
  162. public function getSalt(): ?string
  163. {
  164. return null;
  165. }
  166. /**
  167. * @see UserInterface
  168. */
  169. public function eraseCredentials()
  170. {
  171. // If you store any temporary, sensitive data on the user, clear it here
  172. // $this->plainPassword = null;
  173. }
  174. public function getLockMenu(): ?bool
  175. {
  176. return $this->lockMenu;
  177. }
  178. public function setLockMenu(bool $lockMenu): self
  179. {
  180. $this->lockMenu = $lockMenu;
  181. return $this;
  182. }
  183. public function getFirstname(): ?string
  184. {
  185. return $this->firstname;
  186. }
  187. public function setFirstname(string $firstname): self
  188. {
  189. $this->firstname = $firstname;
  190. return $this;
  191. }
  192. public function getLastname(): ?string
  193. {
  194. return $this->lastname;
  195. }
  196. public function setLastname(string $lastname): self
  197. {
  198. $this->lastname = $lastname;
  199. return $this;
  200. }
  201. public function getCategory(): ?Category
  202. {
  203. return $this->category;
  204. }
  205. public function setCategory(?Category $category): self
  206. {
  207. $this->category = $category;
  208. return $this;
  209. }
  210. public function getStyleButton(): ?bool
  211. {
  212. return $this->styleButton;
  213. }
  214. public function setStyleButton(bool $styleButton): self
  215. {
  216. $this->styleButton = $styleButton;
  217. return $this;
  218. }
  219. public function getFirstConnexion(): ?bool
  220. {
  221. return $this->firstConnexion;
  222. }
  223. public function setFirstConnexion(bool $firstConnexion): self
  224. {
  225. $this->firstConnexion = $firstConnexion;
  226. return $this;
  227. }
  228. public function getDark(): ?bool
  229. {
  230. return $this->dark;
  231. }
  232. public function setDark(bool $dark): self
  233. {
  234. $this->dark = $dark;
  235. return $this;
  236. }
  237. public function getEnable(): ?bool
  238. {
  239. return $this->enable;
  240. }
  241. public function setEnable(bool $enable): self
  242. {
  243. $this->enable = $enable;
  244. return $this;
  245. }
  246. public function getNumberElementPerPage(): ?int
  247. {
  248. return $this->numberElementPerPage;
  249. }
  250. public function setNumberElementPerPage(int $numberElementPerPage): self
  251. {
  252. $this->numberElementPerPage = $numberElementPerPage;
  253. return $this;
  254. }
  255. public function getInitials(): ?string
  256. {
  257. return $this->initials;
  258. }
  259. public function setInitials(string $initials): self
  260. {
  261. $this->initials = $initials;
  262. return $this;
  263. }
  264. public function getDisplayMyIntervention(): ?bool
  265. {
  266. return $this->displayMyIntervention;
  267. }
  268. public function setDisplayMyIntervention(bool $displayMyIntervention): self
  269. {
  270. $this->displayMyIntervention = $displayMyIntervention;
  271. return $this;
  272. }
  273. /**
  274. * @return Collection<int, Intervention>
  275. */
  276. public function getInterventionFav(): Collection
  277. {
  278. return $this->interventionFav;
  279. }
  280. public function addInterventionFav(Intervention $interventionFav): self
  281. {
  282. if (!$this->interventionFav->contains($interventionFav)) {
  283. $this->interventionFav[] = $interventionFav;
  284. }
  285. return $this;
  286. }
  287. public function removeInterventionFav(Intervention $interventionFav): self
  288. {
  289. $this->interventionFav->removeElement($interventionFav);
  290. return $this;
  291. }
  292. public function isFav(Intervention $intervention):Bool{
  293. return $this->interventionFav->contains($intervention);
  294. }
  295. public function getLastStartImportDate(): ?\DateTimeInterface
  296. {
  297. return $this->lastStartImportDate;
  298. }
  299. public function setLastStartImportDate(?\DateTimeInterface $lastStartImportDate): void
  300. {
  301. $this->lastStartImportDate = $lastStartImportDate;
  302. }
  303. public function getLastEndImportDate(): ?\DateTimeInterface
  304. {
  305. return $this->lastEndImportDate;
  306. }
  307. public function setLastEndImportDate(?\DateTimeInterface $lastEndImportDate): void
  308. {
  309. $this->lastEndImportDate = $lastEndImportDate;
  310. }
  311. }