Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
trash
/
vhost_www.traiteur-75.fr_1689065491
/
htdocs
/
src
/
Entity
/
/srv/data/trash/vhost_www.traiteur-75.fr_1689065491/htdocs/src/Entity/User.php
<?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use App\Repository\UserRepository; use App\Repository\WishlistRepository; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Validator\Constraints as Assert; // va nous permettre de sécuriser notre formulaire /** * @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="json") */ private $roles = []; /** * @var string The hashed password * @ORM\Column(type="string") */ private $password; /** * @ORM\Column(type="string", length=255) */ private $firstname; /** * @ORM\Column(type="string", length=255) */ private $lastname; /** * @ORM\Column(type="string", length=255) */ private $fullname; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\Column(type="datetime", nullable=true) */ private $updatedAt; /** * @ORM\Column(type="string", length=255) */ private $phone; /** * @ORM\OneToMany(targetEntity=Wishlist::class, mappedBy="user") */ private $wishlists; /** * @Assert\EqualTo(propertyPath="password", message="Vous n'avez pas correctement confirmé votre mot de passe !") */ public $passwordConfirm; /** * @ORM\OneToOne(targetEntity=Address::class, inversedBy="user", cascade={"persist", "remove"}) */ private $deliveryAddress; /** * @ORM\OneToMany(targetEntity=Command::class, mappedBy="user") */ private $commands; public function __construct(){ $this->createdAt = new \DateTime(); $this->wishlists = new ArrayCollection(); $this->commands = 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 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 getFullname(): ?string { return $this->fullname; } public function setFullname(string $fullname): self { $this->fullname = $fullname; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function getPhone(): ?string { return $this->phone; } public function setPhone(string $phone): self { $this->phone = $phone; return $this; } /** * @return Collection<int, Wishlist> */ public function getWishlists(): Collection { return $this->wishlists; } public function addWishlist(Wishlist $wishlist): self { if (!$this->wishlists->contains($wishlist)) { $this->wishlists[] = $wishlist; $wishlist->setUser($this); } return $this; } public function removeWishlist(Wishlist $wishlist): self { if ($this->wishlists->removeElement($wishlist)) { // set the owning side to null (unless already changed) if ($wishlist->getUser() === $this) { $wishlist->setUser(null); } } return $this; } public function isWishlist(Product $product, WishlistRepository $wishlistRepo){ $wishlists = $wishlistRepo->findBy(["user" => $this]); foreach( $wishlists as $wishlist){ if($wishlist->getProduct() == $product){ return true; } } return false; } public function getDeliveryAddress(): ?Address { return $this->deliveryAddress; } public function setDeliveryAddress(?Address $deliveryAddress): self { $this->deliveryAddress = $deliveryAddress; return $this; } /** * @return Collection<int, Command> */ public function getCommands(): Collection { return $this->commands; } public function addCommand(Command $command): self { if (!$this->commands->contains($command)) { $this->commands[] = $command; $command->setUser($this); } return $this; } public function removeCommand(Command $command): self { if ($this->commands->removeElement($command)) { // set the owning side to null (unless already changed) if ($command->getUser() === $this) { $command->setUser(null); } } return $this; } }