<?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;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $clientName;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $represantantFirstName;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $represantantLastName;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $adresse;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $complement;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $codePostal;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $ville;
/**
* @var datetime $created
*
* @ORM\Column(type="datetime",nullable=true)
*/
protected $created;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\ManyToOne(targetEntity=Client::class, inversedBy="user")
* @ORM\JoinColumn(onDelete="SET NULL", nullable=true)
*/
private $client;
/**
* @ORM\ManyToOne(targetEntity=Society::class, inversedBy="user")
* @ORM\JoinColumn(onDelete="SET NULL", nullable=true)
*/
private $society;
/**
* @ORM\OneToMany(targetEntity=UserAccess::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $userAccesses;
/**
* @ORM\OneToMany(targetEntity=UserSocietyActivities::class, mappedBy="user", cascade={"remove"})
*/
private $userSocietyActivities;
/**
* @ORM\OneToMany(targetEntity=Contact::class, mappedBy="user", cascade={"remove"})
*/
private $contacts;
/**
* @ORM\OneToMany(targetEntity=UserClauseSelection::class, mappedBy="user", cascade={"remove"})
*/
private $clause;
public function __construct()
{
$this->isActive = true;
// may not be needed, see section on salt below
// $this->salt = md5(uniqid('', true));
$this->userAccesses = new ArrayCollection();
$this->userSocietyActivities = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->clause = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
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 store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
public function getSociety(): ?Society
{
return $this->society;
}
public function setSociety(?Society $society): self
{
$this->society = $society;
return $this;
}
/**
* @return mixed
*/
public function getClientName()
{
return $this->clientName;
}
/**
* @param mixed $clientName
*/
public function setClientName($clientName): void
{
$this->clientName = $clientName;
}
/**
* @return mixed
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* @param mixed $adresse
*/
public function setAdresse($adresse): void
{
$this->adresse = $adresse;
}
/**
* @return mixed
*/
public function getComplement()
{
return $this->complement;
}
/**
* @param mixed $complement
*/
public function setComplement($complement): void
{
$this->complement = $complement;
}
/**
* @return mixed
*/
public function getCodePostal()
{
return $this->codePostal;
}
/**
* @param mixed $codePostal
*/
public function setCodePostal($codePostal): void
{
$this->codePostal = $codePostal;
}
/**
* @return mixed
*/
public function getVille()
{
return $this->ville;
}
/**
* @param mixed $ville
*/
public function setVille($ville): void
{
$this->ville = $ville;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->isActive;
}
/**
* @param bool $isActive
*/
public function setIsActive(bool $isActive): void
{
$this->isActive = $isActive;
}
/**
* @return datetime
*/
public function getCreated()
{
return $this->created;
}
/**
* @param datetime $created
*/
public function setCreated($created): void
{
$this->created = $created;
}
/**
* @return mixed
*/
public function getRepresantantFirstName()
{
return $this->represantantFirstName;
}
/**
* @param mixed $represantantFirstName
*/
public function setRepresantantFirstName($represantantFirstName): void
{
$this->represantantFirstName = $represantantFirstName;
}
/**
* @return mixed
*/
public function getRepresantantLastName()
{
return $this->represantantLastName;
}
/**
* @param mixed $represantantLastName
*/
public function setRepresantantLastName($represantantLastName): void
{
$this->represantantLastName = $represantantLastName;
}
/**
* @return Collection<int, UserAccess>
*/
public function getUserAccesses(): Collection
{
return $this->userAccesses;
}
public function addUserAccess(UserAccess $userAccess): self
{
if (!$this->userAccesses->contains($userAccess)) {
$this->userAccesses[] = $userAccess;
$userAccess->setUser($this);
}
return $this;
}
public function removeUserAccess(UserAccess $userAccess): self
{
if ($this->userAccesses->removeElement($userAccess)) {
// set the owning side to null (unless already changed)
if ($userAccess->getUser() === $this) {
$userAccess->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, UserSocietyActivities>
*/
public function getUserSocietyActivities(): Collection
{
return $this->userSocietyActivities;
}
public function addUserSocietyActivity(UserSocietyActivities $userSocietyActivity): self
{
if (!$this->userSocietyActivities->contains($userSocietyActivity)) {
$this->userSocietyActivities[] = $userSocietyActivity;
$userSocietyActivity->setUser($this);
}
return $this;
}
public function removeUserSocietyActivity(UserSocietyActivities $userSocietyActivity): self
{
if ($this->userSocietyActivities->removeElement($userSocietyActivity)) {
// set the owning side to null (unless already changed)
if ($userSocietyActivity->getUser() === $this) {
$userSocietyActivity->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts[] = $contact;
$contact->setUser($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->removeElement($contact)) {
// set the owning side to null (unless already changed)
if ($contact->getUser() === $this) {
$contact->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, UserClauseSelection>
*/
public function getClause(): Collection
{
return $this->clause;
}
public function addClause(UserClauseSelection $clause): self
{
if (!$this->clause->contains($clause)) {
$this->clause[] = $clause;
$clause->setUser($this);
}
return $this;
}
public function removeClause(UserClauseSelection $clause): self
{
if ($this->clause->removeElement($clause)) {
// set the owning side to null (unless already changed)
if ($clause->getUser() === $this) {
$clause->setUser(null);
}
}
return $this;
}
}