src/Entity/User.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Special\VotingInfo;
  4. use App\Repository\UserRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  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 UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $username;
  26.     /**
  27.      * @ORM\Column(type="json")
  28.      */
  29.     private $roles = [];
  30.     /**
  31.      * @var string The hashed password
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $password;
  35.     /**
  36.      * @ORM\Column(type="boolean")
  37.      */
  38.     private $enabled;
  39.     /**
  40.      * @ORM\Column(type="datetime", nullable=true)
  41.      */
  42.     private $lastConnection;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $email;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity=PersonLog::class, mappedBy="userChange")
  49.      */
  50.     private $personLogs;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=Person::class, mappedBy="captureUser")
  53.      */
  54.     private $persons;
  55.     /**
  56.      * @ORM\Column(type="boolean")
  57.      */
  58.     private $isSpecial;
  59.     /**
  60.      * @ORM\OneToMany(targetEntity=Person::class, mappedBy="specialUser")
  61.      */
  62.     private $coordinators;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity=VotingInfo::class, mappedBy="createdBy")
  65.      */
  66.     private $votingInfos;
  67.     public function __construct()
  68.     {
  69.         $this->personLogs = new ArrayCollection();
  70.         $this->persons = new ArrayCollection();
  71.         $this->coordinators = new ArrayCollection();
  72.         $this->votingInfos = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     /**
  79.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  80.      */
  81.     public function getUsername(): string
  82.     {
  83.         return (string) $this->username;
  84.     }
  85.     public function setUsername(string $username): self
  86.     {
  87.         $this->username $username;
  88.         return $this;
  89.     }
  90.     /**
  91.      * A visual identifier that represents this user.
  92.      *
  93.      * @see UserInterface
  94.      */
  95.     public function getUserIdentifier(): string
  96.     {
  97.         return (string) $this->username;
  98.     }
  99.     /**
  100.      * @see UserInterface
  101.      */
  102.     public function getRoles(): array
  103.     {
  104.         $roles $this->roles;
  105.         return array_unique($roles);
  106.     }
  107.     public function setRoles(array $roles): self
  108.     {
  109.         $this->roles $roles;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @see PasswordAuthenticatedUserInterface
  114.      */
  115.     public function getPassword(): string
  116.     {
  117.         return $this->password;
  118.     }
  119.     public function setPassword(string $password): self
  120.     {
  121.         $this->password $password;
  122.         return $this;
  123.     }
  124.     /**
  125.      * Returning a salt is only needed, if you are not using a modern
  126.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  127.      *
  128.      * @see UserInterface
  129.      */
  130.     public function getSalt(): ?string
  131.     {
  132.         return null;
  133.     }
  134.     /**
  135.      * @see UserInterface
  136.      */
  137.     public function eraseCredentials()
  138.     {
  139.         // If you store any temporary, sensitive data on the user, clear it here
  140.         // $this->plainPassword = null;
  141.     }
  142.     public function isEnabled(): ?bool
  143.     {
  144.         return $this->enabled;
  145.     }
  146.     public function setEnabled(bool $enabled): self
  147.     {
  148.         $this->enabled $enabled;
  149.         return $this;
  150.     }
  151.     public function getLastConnection(): ?\DateTimeInterface
  152.     {
  153.         return $this->lastConnection;
  154.     }
  155.     public function setLastConnection(\DateTimeInterface $lastConnection): self
  156.     {
  157.         $this->lastConnection $lastConnection;
  158.         return $this;
  159.     }
  160.     public function getEmail(): ?string
  161.     {
  162.         return $this->email;
  163.     }
  164.     public function setEmail(string $email): self
  165.     {
  166.         $this->email $email;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, PersonLog>
  171.      */
  172.     public function getPersonLogs(): Collection
  173.     {
  174.         return $this->personLogs;
  175.     }
  176.     public function addPersonLog(PersonLog $personLog): self
  177.     {
  178.         if (!$this->personLogs->contains($personLog)) {
  179.             $this->personLogs[] = $personLog;
  180.             $personLog->setUserChange($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removePersonLog(PersonLog $personLog): self
  185.     {
  186.         if ($this->personLogs->removeElement($personLog)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($personLog->getUserChange() === $this) {
  189.                 $personLog->setUserChange(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return Collection<int, Person>
  196.      */
  197.     public function getPersons(): Collection
  198.     {
  199.         return $this->persons;
  200.     }
  201.     public function addPerson(Person $person): self
  202.     {
  203.         if (!$this->persons->contains($person)) {
  204.             $this->persons[] = $person;
  205.             $person->setCaptureUser($this);
  206.         }
  207.         return $this;
  208.     }
  209.     public function removePerson(Person $person): self
  210.     {
  211.         if ($this->persons->removeElement($person)) {
  212.             // set the owning side to null (unless already changed)
  213.             if ($person->getCaptureUser() === $this) {
  214.                 $person->setCaptureUser(null);
  215.             }
  216.         }
  217.         return $this;
  218.     }
  219.     public function isIsSpecial(): ?bool
  220.     {
  221.         return $this->isSpecial;
  222.     }
  223.     public function setIsSpecial(bool $isSpecial): self
  224.     {
  225.         $this->isSpecial $isSpecial;
  226.         return $this;
  227.     }
  228.     /**
  229.      * @return Collection<int, Person>
  230.      */
  231.     public function getCoordinators(): Collection
  232.     {
  233.         return $this->coordinators;
  234.     }
  235.     public function addCoordinator(Person $coordinator): self
  236.     {
  237.         if (!$this->coordinators->contains($coordinator)) {
  238.             $this->coordinators[] = $coordinator;
  239.             $coordinator->setSpecialUser($this);
  240.         }
  241.         return $this;
  242.     }
  243.     public function removeCoordinator(Person $coordinator): self
  244.     {
  245.         if ($this->coordinators->removeElement($coordinator)) {
  246.             // set the owning side to null (unless already changed)
  247.             if ($coordinator->getSpecialUser() === $this) {
  248.                 $coordinator->setSpecialUser(null);
  249.             }
  250.         }
  251.         return $this;
  252.     }
  253.     /**
  254.      * @return Collection<int, VotingInfo>
  255.      */
  256.     public function getVotingInfos(): Collection
  257.     {
  258.         return $this->votingInfos;
  259.     }
  260.     public function addVotingInfo(VotingInfo $votingInfo): self
  261.     {
  262.         if (!$this->votingInfos->contains($votingInfo)) {
  263.             $this->votingInfos[] = $votingInfo;
  264.             $votingInfo->setCreatedBy($this);
  265.         }
  266.         return $this;
  267.     }
  268.     public function removeVotingInfo(VotingInfo $votingInfo): self
  269.     {
  270.         if ($this->votingInfos->removeElement($votingInfo)) {
  271.             // set the owning side to null (unless already changed)
  272.             if ($votingInfo->getCreatedBy() === $this) {
  273.                 $votingInfo->setCreatedBy(null);
  274.             }
  275.         }
  276.         return $this;
  277.     }
  278. }