src/Entity/User.php line 44
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use App\EntityListener\UserListener;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use App\Repository\UserRepository;use Serializable;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\HttpFoundation\File\File;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Serializer\Annotation\Groups;use Vich\UploaderBundle\Mapping\Annotation as Vich;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\Table(name: '`app_user`')]#[ORM\HasLifecycleCallbacks]#[Vich\Uploadable]#[UniqueEntity(fields: ['username'], message: 'Il existe déjà un compte avec cet identifiant.')]#[ORM\EntityListeners([UserListener::class])]#[ApiResource(operations: [new Get(normalizationContext: ['groups' => 'user:item']),new GetCollection(normalizationContext: ['groups' => 'user:list']),],paginationEnabled: false,)]class User implements UserInterface, PasswordAuthenticatedUserInterface, Serializable{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['user:list', 'user:item', 'assignment:item', 'assignment:list'])]private ?int $id = null;#[ORM\Column(name: '`user_login`', length: 255, unique: true)]#[Groups(['user:list', 'user:item'])]private ?string $username = null;#[ORM\Column(name: '`display_name`', length: 255, nullable: true)]#[Groups(['user:list', 'user:item', 'assignment:item'])]private ?string $displayName = null;#[ORM\ManyToOne(inversedBy: 'users')]#[ORM\JoinColumn(nullable: true)]#[Groups(['user:list', 'user:item'])]private ?Role $role = null;#[ORM\Column(type: Types::BOOLEAN, nullable: true, options: ["default" => 0])]#[Groups(['user:list', 'user:item'])]private ?bool $isClient = null;#[ORM\ManyToOne(inversedBy: 'users')]#[ORM\JoinColumn(nullable: true)]#[Groups(['user:list', 'user:item'])]private ?Client $client = null;#[ORM\Column(name: '`user_pass`')]#[Groups(['user:list', 'user:item'])]private ?string $password = null;#[ORM\Column(name: '`user_email`', length: 255)]#[Groups(['user:list', 'user:item'])]private ?string $email = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user:list', 'user:item'])]private ?string $phone = null;#[ORM\Column(type: Types::STRING, length: 255, nullable: true, options: ["default" => null])]#[Groups(['user:list', 'user:item'])]private ?string $imageName = null;#[Vich\UploadableField(mapping: 'user_img', fileNameProperty: 'imageName', size: 'imageSize')]private ?File $imageFile = null;#[ORM\Column(type: 'integer', nullable: true)]private ?int $imageSize = null;#[ORM\Column(type: Types::BOOLEAN, options: ["default" => "0"])]private bool $isVerified = false;#[ORM\Column(type: Types::DATETIME_IMMUTABLE, options: ["default" => "CURRENT_TIMESTAMP"])]private ?DateTimeImmutable $createdAt = null;#[ORM\Column(type: Types::DATETIME_IMMUTABLE, options: ["default" => "CURRENT_TIMESTAMP"])]private ?DateTimeImmutable $updatedAt = null;#[ORM\Column(type: Types::BOOLEAN, options: ["default" => "0"])]#[Groups(['user:list', 'user:item'])]private ?bool $isActivated = false;#[ORM\Column(type: Types::BOOLEAN, options: ["default" => "0"])]#[Groups(['user:list', 'user:item'])]private ?bool $isDeleted = false;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Card::class)]private Collection $cards;public function __construct(){$this->cards = 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 PasswordAuthenticatedUserInterface*/public function getPassword(): string{if ($this->password != null)return $this->password;return "";}/*** @param string|null $password* @return $this*/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 getDisplayName(): ?string{return $this->displayName;}public function setDisplayName(?string $displayName): self{$this->displayName = $displayName;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): self{$this->email = $email;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(?string $phone): self{$this->phone = $phone;return $this;}/*** @return string|null*/public function getImageName(): ?string{return $this->imageName;}/*** @param string|null $imageName*/public function setImageName(?string $imageName): void{$this->imageName = $imageName;}/*** @param File|null $imageFile*/public function setImageFile(?File $imageFile = null): void{$this->imageFile = $imageFile;if (null !== $imageFile) {$this->updatedAt = new DateTimeImmutable;}}public function getImageFile(): ?File{return $this->imageFile;}public function setImageSize(?int $imageSize): void{$this->imageSize = $imageSize;}public function getImageSize(): ?int{return $this->imageSize;}public function isVerified(): bool{return $this->isVerified;}public function setIsVerified(?bool $isVerified): self{$this->isVerified = $isVerified;return $this;}public function getCreatedAt(): ?DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(?DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getUpdatedAt(): ?DateTimeImmutable{return $this->updatedAt;}public function setUpdatedAt(?DateTimeImmutable $updatedAt): self{$this->updatedAt = $updatedAt;return $this;}public function isIsActivated(): ?bool{return $this->isActivated;}public function setIsActivated(bool $isActivated): self{$this->isActivated = $isActivated;return $this;}public function isIsDeleted(): ?bool{return $this->isDeleted;}public function setIsDeleted(bool $isDeleted): self{$this->isDeleted = $isDeleted;return $this;}public function getRole(): ?Role{return $this->role;}public function setRole(?Role $role): self{$this->role = $role;return $this;}public function getRoles(): array{$roles = [];$roles[] = 'ROLE_USER';if ($this->getRole() != null)$roles[] = $this->getRole()->getAlias();return array_unique($roles);}/** @see \Serializable::serialize() */public function serialize(): ?string{return serialize(array($this->id,$this->username,$this->displayName,$this->password,$this->email,$this->phone,$this->isVerified,$this->isActivated,));}/** @param $serialized* @see \Serializable::unserialize()*/public function unserialize($serialized){list ($this->id,$this->username,$this->displayName,$this->password,$this->email,$this->phone,$this->isVerified,$this->isActivated,) = unserialize($serialized, array('allowed_classes' => false));}public function getClient(): ?Client{return $this->client;}public function setClient(?Client $client): self{$this->client = $client;return $this;}/*** @return Collection<int, Card>*/public function getCards(): Collection{return $this->cards;}public function addCard(Card $card): self{if (!$this->cards->contains($card)) {$this->cards->add($card);$card->setUser($this);}return $this;}public function removeCard(Card $card): self{if ($this->cards->removeElement($card)) {// set the owning side to null (unless already changed)if ($card->getUser() === $this) {$card->setUser(null);}}return $this;}public function isIsClient(): ?bool{return $this->isClient;}public function setIsClient(?bool $isClient): self{$this->isClient = $isClient;return $this;}}