src/Entity/Gestiform/Users/User.php line 35
<?phpnamespace App\Entity\Gestiform\Users;use App\Entity\AbstractEntity;use App\Entity\Common\Adresse;use App\Entity\Common\Upload;use App\Entity\Trait\ApiGestiformEntity;use App\Enums\RolesEnum;use App\Repository\Gestiform\Users\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\ORM\Mapping as ORM;use Doctrine\ORM\Mapping\DiscriminatorColumn;use Doctrine\ORM\Mapping\DiscriminatorMap;use Doctrine\ORM\Mapping\InheritanceType;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Validator\Constraints\NotBlank;#[ORM\Entity(repositoryClass: UserRepository::class)]#[UniqueEntity('email', message: 'cette adresse email est déja prise')]#[InheritanceType('JOINED')]#[DiscriminatorColumn(name: 'type', type: 'string')]#[DiscriminatorMap(['user' => User::class, 'employe' => Employe::class, 'apprenant' => Apprenant::class, 'formateur' => Formateur::class, 'personne' => Personne::class])]class User extends AbstractEntity implements UserInterface, PasswordAuthenticatedUserInterface{use ApiGestiformEntity;#[ORM\Column(type: 'string', length: 255, nullable: false)]#[NotBlank]protected string $email;#[ORM\Column(type: 'string', length: 500, nullable: true)]protected ?string $password = null;#[ORM\Column(type: 'string', length: 500, nullable: true)]private ?string $plainPassword = null;#[ORM\Column(type: 'json')]protected array $roles = [];#[ORM\Column(type: 'boolean')]protected bool $enabled = true;#[ORM\Column(type: 'boolean', nullable: true)]protected ?bool $status = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $rgpd = false;#[ORM\JoinColumn(nullable: true)]#[ORM\ManyToOne(targetEntity: Adresse::class, cascade: ['all'])]protected ?Adresse $adresse = null;#[ORM\JoinColumn(nullable: true)]#[ORM\OneToOne(targetEntity: Upload::class, cascade: ['persist', 'remove'])]protected ?Upload $photo = null;public function getEmail(): string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}public function getPassword(): ?string{return $this->password;}public function setPassword(?string $password): self{$this->password = $password;return $this;}public function getStatus(): ?bool{return $this->status;}public function setStatus(?bool $status): self{$this->status = $status;return $this;}public function getRoles(): array{$roles = $this->roles;$roles[] = RolesEnum::ROLE_MEMBRE->value;return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}public function addRole(string $role): self{if (!in_array($role, $this->getRoles(), true)) {$this->roles = array_merge($this->roles, [$role]);}return $this;}public function removeRoles(): self{$this->roles = [];return $this;}public function removeRole(string $role): self{$this->roles = array_diff($this->roles, [$role]);return $this;}public function hasRole(string $role): bool{return in_array($role, $this->getRoles(), true);}/*** @param string[][] $rolesListsToCheck* @return bool* check with logic OR between args and logic AND between same array*/public function hasRoles(array ...$rolesListsToCheck): bool{$roles = new ArrayCollection($this->getRoles());foreach ($rolesListsToCheck as $rolesToCheck) {if ($roles->filter(fn(string $role) => in_array($role, $rolesToCheck))->count() !== 0) {return true;}}return false;}public function getUserIdentifier(): string{return $this->email;}public function getSalt(): ?string{return null;}public function getUsername(): string{return $this->getUserIdentifier();}public function setEnabled(bool $enabled): self{$this->enabled = $enabled;return $this;}public function isEnabled(): ?bool{return $this->enabled;}public function getAdresse(): ?Adresse{return $this->adresse;}public function setAdresse(?Adresse $adresse): self{$this->adresse = $adresse;return $this;}public function getPhoto(): ?Upload{return $this->photo;}public function setPhoto(?Upload $photo): self{$this->photo = $photo;return $this;}public function isRgpd(): ?bool{return $this->rgpd;}public function setRgpd(?bool $rgpd): User{$this->rgpd = $rgpd;return $this;}public function isStatus(): ?bool{return $this->status;}public function eraseCredentials(): void{$this->plainPassword = null; // Nettoyage du mot de passe en clair}public function getPlainPassword(): ?string{return $this->plainPassword;}public function setPlainPassword(?string $plainPassword): self{$this->plainPassword = $plainPassword;return $this;}}