123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- namespace App\Entity;
- use App\Repository\UserRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Validator\Constraints as Assert;
- class User implements UserInterface, PasswordAuthenticatedUserInterface
- {
-
-
-
- private ?int $id = null;
-
-
- private ?string $email = null;
-
-
- private array $roles = [];
-
-
- private ?string $password = null;
-
-
- private Collection $commonLists;
-
-
- private Collection $userLists;
-
- private ?string $name = null;
- public function __construct()
- {
- $this->commonLists = new ArrayCollection();
- $this->userLists = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getEmail(): ?string
- {
- return $this->email;
- }
- public function setEmail(string $email): static
- {
- $this->email = $email;
- return $this;
- }
-
- public function getUserIdentifier(): string
- {
- return (string) $this->email;
- }
-
- public function getRoles(): array
- {
- $roles = $this->roles;
-
- $roles[] = 'ROLE_USER';
- return array_unique($roles);
- }
-
- public function setRoles(array $roles): static
- {
- $this->roles = $roles;
- return $this;
- }
-
- public function getPassword(): ?string
- {
- return $this->password;
- }
- public function setPassword(string $password): static
- {
- $this->password = $password;
- return $this;
- }
-
- public function eraseCredentials(): void
- {
-
-
- }
-
- public function getCommonLists(): Collection
- {
- return $this->commonLists;
- }
- public function addCommonList(CommonList $commonList): static
- {
- if (!$this->commonLists->contains($commonList)) {
- $this->commonLists->add($commonList);
- $commonList->setAddedBy($this);
- }
- return $this;
- }
- public function removeCommonList(CommonList $commonList): static
- {
- if ($this->commonLists->removeElement($commonList)) {
-
- if ($commonList->getAddedBy() === $this) {
- $commonList->setAddedBy(null);
- }
- }
- return $this;
- }
-
- public function getUserLists(): Collection
- {
- return $this->userLists;
- }
- public function addUserList(UserList $userList): static
- {
- if (!$this->userLists->contains($userList)) {
- $this->userLists->add($userList);
- $userList->setViewer($this);
- }
- return $this;
- }
- public function removeUserList(UserList $userList): static
- {
- if ($this->userLists->removeElement($userList)) {
-
- if ($userList->getViewer() === $this) {
- $userList->setViewer(null);
- }
- }
- return $this;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(?string $name): static
- {
- $this->name = $name;
- return $this;
- }
- public function getPseudo(): string
- {
- return $this->getName() ?? $this->getEmail();
- }
- }
|