<?php
namespace App\Entity;
use App\Repository\DistributorUsersRepository;
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: DistributorUsersRepository::class)]
class DistributorUsers implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Distributors::class, inversedBy: 'distributorUsers')]
private $distributor;
#[ORM\Column(type: 'string', length: 255)]
private $firstName;
#[ORM\Column(type: 'string', length: 255)]
private $lastName;
#[ORM\Column(type: 'string', length: 255)]
private $position;
#[ORM\Column(type: 'string', length: 255)]
private $email;
/**
* @var string The hashed password
*/
#[ORM\Column(type: 'string')]
private $password;
#[ORM\Column(type: 'json')]
private $roles = [];
#[ORM\Column(type: 'datetime')]
private $modified;
#[ORM\Column(type: 'datetime')]
private $created;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $telephone;
#[ORM\Column(type: 'boolean')]
private $isPrimary;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $isoCode;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $intlCode;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $resetKey;
#[ORM\OneToMany(targetEntity: DistributorUserPermissions::class, mappedBy: 'user')]
private $distributorUserPermissions;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $hashedEmail;
public function __construct()
{
$this->setModified(new \DateTime());
if ($this->getCreated() == null) {
$this->setCreated(new \DateTime());
}
$this->distributorUserPermissions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDistributor(): ?Distributors
{
return $this->distributor;
}
public function setDistributor(?Distributors $distributor): self
{
$this->distributor = $distributor;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(string $position): self
{
$this->position = $position;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getModified(): ?\DateTimeInterface
{
return $this->modified;
}
public function setModified(\DateTimeInterface $modified): self
{
$this->modified = $modified;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
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 inventory any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(?string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getIsPrimary(): ?bool
{
return $this->isPrimary;
}
public function setIsPrimary(bool $isPrimary): self
{
$this->isPrimary = $isPrimary;
return $this;
}
public function getIsoCode(): ?string
{
return $this->isoCode;
}
public function setIsoCode(?string $isoCode): self
{
$this->isoCode = $isoCode;
return $this;
}
public function getIntlCode(): ?string
{
return $this->intlCode;
}
public function setIntlCode(?string $intlCode): self
{
$this->intlCode = $intlCode;
return $this;
}
public function getResetKey(): ?string
{
return $this->resetKey;
}
public function setResetKey(?string $resetKey): self
{
$this->resetKey = $resetKey;
return $this;
}
/**
* @return Collection<int, DistributorUserPermissions>
*/
public function getDistributorUserPermissions(): Collection
{
return $this->distributorUserPermissions;
}
public function addDistributorUserPermission(DistributorUserPermissions $distributorUserPermission): self
{
if (!$this->distributorUserPermissions->contains($distributorUserPermission)) {
$this->distributorUserPermissions[] = $distributorUserPermission;
$distributorUserPermission->setUser($this);
}
return $this;
}
public function removeDistributorUserPermission(DistributorUserPermissions $distributorUserPermission): self
{
if ($this->distributorUserPermissions->removeElement($distributorUserPermission)) {
// set the owning side to null (unless already changed)
if ($distributorUserPermission->getUser() === $this) {
$distributorUserPermission->setUser(null);
}
}
return $this;
}
public function getHashedEmail(): ?string
{
return $this->hashedEmail;
}
public function setHashedEmail(?string $hashedEmail): self
{
$this->hashedEmail = $hashedEmail;
return $this;
}
}