src/Entity/User.php line 14
<?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)]
#[ORM\Table(name: 'ujr_users')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Directeur::class)]
private Collection $directeurs;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: ResponsableStructure::class)]
private Collection $responsableStructures;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Chercheur::class)]
private Collection $chercheurs;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Projet::class)]
private Collection $projets;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Tag::class)]
private Collection $tags;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Publication::class)]
private Collection $publications;
#[ORM\Column(length: 255, nullable: true)]
private ?string $username = null;
#[ORM\Column(nullable: true)]
private ?int $etat = null;
public function __construct()
{
$this->directeurs = new ArrayCollection();
$this->responsableStructures = new ArrayCollection();
$this->chercheurs = new ArrayCollection();
$this->projets = new ArrayCollection();
$this->tags = new ArrayCollection();
$this->publications = 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;
}
/**
* @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;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, Directeur>
*/
public function getDirecteurs(): Collection
{
return $this->directeurs;
}
public function addDirecteur(Directeur $directeur): self
{
if (!$this->directeurs->contains($directeur)) {
$this->directeurs->add($directeur);
$directeur->setUser($this);
}
return $this;
}
public function removeDirecteur(Directeur $directeur): self
{
if ($this->directeurs->removeElement($directeur)) {
// set the owning side to null (unless already changed)
if ($directeur->getUser() === $this) {
$directeur->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, ResponsableStructure>
*/
public function getResponsableStructures(): Collection
{
return $this->responsableStructures;
}
public function addResponsableStructure(ResponsableStructure $responsableStructure): self
{
if (!$this->responsableStructures->contains($responsableStructure)) {
$this->responsableStructures->add($responsableStructure);
$responsableStructure->setUser($this);
}
return $this;
}
public function removeResponsableStructure(ResponsableStructure $responsableStructure): self
{
if ($this->responsableStructures->removeElement($responsableStructure)) {
// set the owning side to null (unless already changed)
if ($responsableStructure->getUser() === $this) {
$responsableStructure->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Chercheur>
*/
public function getChercheurs(): Collection
{
return $this->chercheurs;
}
public function addChercheur(Chercheur $chercheur): self
{
if (!$this->chercheurs->contains($chercheur)) {
$this->chercheurs->add($chercheur);
$chercheur->setUser($this);
}
return $this;
}
public function removeChercheur(Chercheur $chercheur): self
{
if ($this->chercheurs->removeElement($chercheur)) {
// set the owning side to null (unless already changed)
if ($chercheur->getUser() === $this) {
$chercheur->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Projet>
*/
public function getProjets(): Collection
{
return $this->projets;
}
public function addProjet(Projet $projet): self
{
if (!$this->projets->contains($projet)) {
$this->projets->add($projet);
$projet->setUser($this);
}
return $this;
}
public function removeProjet(Projet $projet): self
{
if ($this->projets->removeElement($projet)) {
// set the owning side to null (unless already changed)
if ($projet->getUser() === $this) {
$projet->setUser(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->email;
}
/**
* @return Collection<int, Tag>
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): self
{
if (!$this->tags->contains($tag)) {
$this->tags->add($tag);
$tag->setUser($this);
}
return $this;
}
public function removeTag(Tag $tag): self
{
if ($this->tags->removeElement($tag)) {
// set the owning side to null (unless already changed)
if ($tag->getUser() === $this) {
$tag->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Publication>
*/
public function getPublications(): Collection
{
return $this->publications;
}
public function addPublication(Publication $publication): self
{
if (!$this->publications->contains($publication)) {
$this->publications->add($publication);
$publication->setUser($this);
}
return $this;
}
public function removePublication(Publication $publication): self
{
if ($this->publications->removeElement($publication)) {
// set the owning side to null (unless already changed)
if ($publication->getUser() === $this) {
$publication->setUser(null);
}
}
return $this;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
public function getEtat(): ?int
{
return $this->etat;
}
public function setEtat(?int $etat): self
{
$this->etat = $etat;
return $this;
}
}