<?php
namespace App\Entity;
use App\Entity\Special\VotingInfo;
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;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`user`")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="boolean")
*/
private $enabled;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $lastConnection;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
/**
* @ORM\OneToMany(targetEntity=PersonLog::class, mappedBy="userChange")
*/
private $personLogs;
/**
* @ORM\OneToMany(targetEntity=Person::class, mappedBy="captureUser")
*/
private $persons;
/**
* @ORM\Column(type="boolean")
*/
private $isSpecial;
/**
* @ORM\OneToMany(targetEntity=Person::class, mappedBy="specialUser")
*/
private $coordinators;
/**
* @ORM\OneToMany(targetEntity=VotingInfo::class, mappedBy="createdBy")
*/
private $votingInfos;
public function __construct()
{
$this->personLogs = new ArrayCollection();
$this->persons = new ArrayCollection();
$this->coordinators = new ArrayCollection();
$this->votingInfos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
public function getLastConnection(): ?\DateTimeInterface
{
return $this->lastConnection;
}
public function setLastConnection(\DateTimeInterface $lastConnection): self
{
$this->lastConnection = $lastConnection;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* @return Collection<int, PersonLog>
*/
public function getPersonLogs(): Collection
{
return $this->personLogs;
}
public function addPersonLog(PersonLog $personLog): self
{
if (!$this->personLogs->contains($personLog)) {
$this->personLogs[] = $personLog;
$personLog->setUserChange($this);
}
return $this;
}
public function removePersonLog(PersonLog $personLog): self
{
if ($this->personLogs->removeElement($personLog)) {
// set the owning side to null (unless already changed)
if ($personLog->getUserChange() === $this) {
$personLog->setUserChange(null);
}
}
return $this;
}
/**
* @return Collection<int, Person>
*/
public function getPersons(): Collection
{
return $this->persons;
}
public function addPerson(Person $person): self
{
if (!$this->persons->contains($person)) {
$this->persons[] = $person;
$person->setCaptureUser($this);
}
return $this;
}
public function removePerson(Person $person): self
{
if ($this->persons->removeElement($person)) {
// set the owning side to null (unless already changed)
if ($person->getCaptureUser() === $this) {
$person->setCaptureUser(null);
}
}
return $this;
}
public function isIsSpecial(): ?bool
{
return $this->isSpecial;
}
public function setIsSpecial(bool $isSpecial): self
{
$this->isSpecial = $isSpecial;
return $this;
}
/**
* @return Collection<int, Person>
*/
public function getCoordinators(): Collection
{
return $this->coordinators;
}
public function addCoordinator(Person $coordinator): self
{
if (!$this->coordinators->contains($coordinator)) {
$this->coordinators[] = $coordinator;
$coordinator->setSpecialUser($this);
}
return $this;
}
public function removeCoordinator(Person $coordinator): self
{
if ($this->coordinators->removeElement($coordinator)) {
// set the owning side to null (unless already changed)
if ($coordinator->getSpecialUser() === $this) {
$coordinator->setSpecialUser(null);
}
}
return $this;
}
/**
* @return Collection<int, VotingInfo>
*/
public function getVotingInfos(): Collection
{
return $this->votingInfos;
}
public function addVotingInfo(VotingInfo $votingInfo): self
{
if (!$this->votingInfos->contains($votingInfo)) {
$this->votingInfos[] = $votingInfo;
$votingInfo->setCreatedBy($this);
}
return $this;
}
public function removeVotingInfo(VotingInfo $votingInfo): self
{
if ($this->votingInfos->removeElement($votingInfo)) {
// set the owning side to null (unless already changed)
if ($votingInfo->getCreatedBy() === $this) {
$votingInfo->setCreatedBy(null);
}
}
return $this;
}
}