src/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. /**
  10.  * @ORM\Entity(repositoryClass=UserRepository::class)
  11.  */
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=180, unique=true)
  22.      */
  23.     private $email;
  24.     /**
  25.      * @ORM\Column(type="string", length=255,nullable=true)
  26.      */
  27.     private $clientName;
  28.     /**
  29.      * @ORM\Column(type="string", length=255,nullable=true)
  30.      */
  31.     private $represantantFirstName;
  32.     /**
  33.      * @ORM\Column(type="string", length=255,nullable=true)
  34.      */
  35.     private $represantantLastName;
  36.     /**
  37.      * @ORM\Column(type="string", length=255,nullable=true)
  38.      */
  39.     private $adresse;
  40.     /**
  41.      * @ORM\Column(type="string", length=255,nullable=true)
  42.      */
  43.     private $complement;
  44.     /**
  45.      * @ORM\Column(type="string", length=255,nullable=true)
  46.      */
  47.     private $codePostal;
  48.     /**
  49.      * @ORM\Column(name="is_active", type="boolean")
  50.      */
  51.     private $isActive;
  52.     /**
  53.      * @ORM\Column(type="string", length=255,nullable=true)
  54.      */
  55.     private $ville;
  56.     /**
  57.      * @var datetime $created
  58.      *
  59.      * @ORM\Column(type="datetime",nullable=true)
  60.      */
  61.     protected $created;
  62.     /**
  63.      * @ORM\Column(type="json")
  64.      */
  65.     private $roles = [];
  66.     /**
  67.      * @var string The hashed password
  68.      * @ORM\Column(type="string")
  69.      */
  70.     private $password;
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="user")
  73.      * @ORM\JoinColumn(onDelete="SET NULL", nullable=true)
  74.      */
  75.     private $client;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity=Society::class, inversedBy="user")
  78.      * @ORM\JoinColumn(onDelete="SET NULL", nullable=true)
  79.      */
  80.     private $society;
  81.     /**
  82.      * @ORM\OneToMany(targetEntity=UserAccess::class, mappedBy="user", cascade={"persist", "remove"})
  83.      */
  84.     private $userAccesses;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=UserSocietyActivities::class, mappedBy="user", cascade={"remove"})
  87.      */
  88.     private $userSocietyActivities;
  89.     /**
  90.      * @ORM\OneToMany(targetEntity=Contact::class, mappedBy="user", cascade={"remove"})
  91.      */
  92.     private $contacts;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity=UserClauseSelection::class, mappedBy="user", cascade={"remove"})
  95.      */
  96.     private $clause;
  97.     public function __construct()
  98.     {
  99.         $this->isActive true;
  100.         // may not be needed, see section on salt below
  101.         // $this->salt = md5(uniqid('', true));
  102.         $this->userAccesses = new ArrayCollection();
  103.         $this->userSocietyActivities = new ArrayCollection();
  104.         $this->contacts = new ArrayCollection();
  105.         $this->clause = new ArrayCollection();
  106.     }
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getEmail(): ?string
  112.     {
  113.         return $this->email;
  114.     }
  115.     public function setEmail(string $email): self
  116.     {
  117.         $this->email $email;
  118.         return $this;
  119.     }
  120.     /**
  121.      * A visual identifier that represents this user.
  122.      *
  123.      * @see UserInterface
  124.      */
  125.     public function getUserIdentifier(): string
  126.     {
  127.         return (string) $this->email;
  128.     }
  129.     /**
  130.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  131.      */
  132.     public function getUsername(): string
  133.     {
  134.         return (string) $this->email;
  135.     }
  136.     /**
  137.      * @see UserInterface
  138.      */
  139.     public function getRoles(): array
  140.     {
  141.         $roles $this->roles;
  142.         // guarantee every user at least has ROLE_USER
  143.         $roles[] = 'ROLE_USER';
  144.         return array_unique($roles);
  145.     }
  146.     public function setRoles(array $roles): self
  147.     {
  148.         $this->roles $roles;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @see PasswordAuthenticatedUserInterface
  153.      */
  154.     public function getPassword(): string
  155.     {
  156.         return $this->password;
  157.     }
  158.     public function setPassword(string $password): self
  159.     {
  160.         $this->password $password;
  161.         return $this;
  162.     }
  163.     /**
  164.      * Returning a salt is only needed, if you are not using a modern
  165.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  166.      *
  167.      * @see UserInterface
  168.      */
  169.     public function getSalt(): ?string
  170.     {
  171.         return null;
  172.     }
  173.     /**
  174.      * @see UserInterface
  175.      */
  176.     public function eraseCredentials()
  177.     {
  178.         // If you store any temporary, sensitive data on the user, clear it here
  179.         // $this->plainPassword = null;
  180.     }
  181.     public function getClient(): ?Client
  182.     {
  183.         return $this->client;
  184.     }
  185.     public function setClient(?Client $client): self
  186.     {
  187.         $this->client $client;
  188.         return $this;
  189.     }
  190.     public function getSociety(): ?Society
  191.     {
  192.         return $this->society;
  193.     }
  194.     public function setSociety(?Society $society): self
  195.     {
  196.         $this->society $society;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return mixed
  201.      */
  202.     public function getClientName()
  203.     {
  204.         return $this->clientName;
  205.     }
  206.     /**
  207.      * @param mixed $clientName
  208.      */
  209.     public function setClientName($clientName): void
  210.     {
  211.         $this->clientName $clientName;
  212.     }
  213.     /**
  214.      * @return mixed
  215.      */
  216.     public function getAdresse()
  217.     {
  218.         return $this->adresse;
  219.     }
  220.     /**
  221.      * @param mixed $adresse
  222.      */
  223.     public function setAdresse($adresse): void
  224.     {
  225.         $this->adresse $adresse;
  226.     }
  227.     /**
  228.      * @return mixed
  229.      */
  230.     public function getComplement()
  231.     {
  232.         return $this->complement;
  233.     }
  234.     /**
  235.      * @param mixed $complement
  236.      */
  237.     public function setComplement($complement): void
  238.     {
  239.         $this->complement $complement;
  240.     }
  241.     /**
  242.      * @return mixed
  243.      */
  244.     public function getCodePostal()
  245.     {
  246.         return $this->codePostal;
  247.     }
  248.     /**
  249.      * @param mixed $codePostal
  250.      */
  251.     public function setCodePostal($codePostal): void
  252.     {
  253.         $this->codePostal $codePostal;
  254.     }
  255.     /**
  256.      * @return mixed
  257.      */
  258.     public function getVille()
  259.     {
  260.         return $this->ville;
  261.     }
  262.     /**
  263.      * @param mixed $ville
  264.      */
  265.     public function setVille($ville): void
  266.     {
  267.         $this->ville $ville;
  268.     }
  269.     /**
  270.      * @return bool
  271.      */
  272.     public function isActive(): bool
  273.     {
  274.         return $this->isActive;
  275.     }
  276.     /**
  277.      * @param bool $isActive
  278.      */
  279.     public function setIsActive(bool $isActive): void
  280.     {
  281.         $this->isActive $isActive;
  282.     }
  283.     /**
  284.      * @return datetime
  285.      */
  286.     public function getCreated()
  287.     {
  288.         return $this->created;
  289.     }
  290.     /**
  291.      * @param datetime $created
  292.      */
  293.     public function setCreated($created): void
  294.     {
  295.         $this->created $created;
  296.     }
  297.     /**
  298.      * @return mixed
  299.      */
  300.     public function getRepresantantFirstName()
  301.     {
  302.         return $this->represantantFirstName;
  303.     }
  304.     /**
  305.      * @param mixed $represantantFirstName
  306.      */
  307.     public function setRepresantantFirstName($represantantFirstName): void
  308.     {
  309.         $this->represantantFirstName $represantantFirstName;
  310.     }
  311.     /**
  312.      * @return mixed
  313.      */
  314.     public function getRepresantantLastName()
  315.     {
  316.         return $this->represantantLastName;
  317.     }
  318.     /**
  319.      * @param mixed $represantantLastName
  320.      */
  321.     public function setRepresantantLastName($represantantLastName): void
  322.     {
  323.         $this->represantantLastName $represantantLastName;
  324.     }
  325.     /**
  326.      * @return Collection<int, UserAccess>
  327.      */
  328.     public function getUserAccesses(): Collection
  329.     {
  330.         return $this->userAccesses;
  331.     }
  332.     public function addUserAccess(UserAccess $userAccess): self
  333.     {
  334.         if (!$this->userAccesses->contains($userAccess)) {
  335.             $this->userAccesses[] = $userAccess;
  336.             $userAccess->setUser($this);
  337.         }
  338.         return $this;
  339.     }
  340.     public function removeUserAccess(UserAccess $userAccess): self
  341.     {
  342.         if ($this->userAccesses->removeElement($userAccess)) {
  343.             // set the owning side to null (unless already changed)
  344.             if ($userAccess->getUser() === $this) {
  345.                 $userAccess->setUser(null);
  346.             }
  347.         }
  348.         return $this;
  349.     }
  350.     /**
  351.      * @return Collection<int, UserSocietyActivities>
  352.      */
  353.     public function getUserSocietyActivities(): Collection
  354.     {
  355.         return $this->userSocietyActivities;
  356.     }
  357.     public function addUserSocietyActivity(UserSocietyActivities $userSocietyActivity): self
  358.     {
  359.         if (!$this->userSocietyActivities->contains($userSocietyActivity)) {
  360.             $this->userSocietyActivities[] = $userSocietyActivity;
  361.             $userSocietyActivity->setUser($this);
  362.         }
  363.         return $this;
  364.     }
  365.     public function removeUserSocietyActivity(UserSocietyActivities $userSocietyActivity): self
  366.     {
  367.         if ($this->userSocietyActivities->removeElement($userSocietyActivity)) {
  368.             // set the owning side to null (unless already changed)
  369.             if ($userSocietyActivity->getUser() === $this) {
  370.                 $userSocietyActivity->setUser(null);
  371.             }
  372.         }
  373.         return $this;
  374.     }
  375.     /**
  376.      * @return Collection<int, Contact>
  377.      */
  378.     public function getContacts(): Collection
  379.     {
  380.         return $this->contacts;
  381.     }
  382.     public function addContact(Contact $contact): self
  383.     {
  384.         if (!$this->contacts->contains($contact)) {
  385.             $this->contacts[] = $contact;
  386.             $contact->setUser($this);
  387.         }
  388.         return $this;
  389.     }
  390.     public function removeContact(Contact $contact): self
  391.     {
  392.         if ($this->contacts->removeElement($contact)) {
  393.             // set the owning side to null (unless already changed)
  394.             if ($contact->getUser() === $this) {
  395.                 $contact->setUser(null);
  396.             }
  397.         }
  398.         return $this;
  399.     }
  400.     /**
  401.      * @return Collection<int, UserClauseSelection>
  402.      */
  403.     public function getClause(): Collection
  404.     {
  405.         return $this->clause;
  406.     }
  407.     public function addClause(UserClauseSelection $clause): self
  408.     {
  409.         if (!$this->clause->contains($clause)) {
  410.             $this->clause[] = $clause;
  411.             $clause->setUser($this);
  412.         }
  413.         return $this;
  414.     }
  415.     public function removeClause(UserClauseSelection $clause): self
  416.     {
  417.         if ($this->clause->removeElement($clause)) {
  418.             // set the owning side to null (unless already changed)
  419.             if ($clause->getUser() === $this) {
  420.                 $clause->setUser(null);
  421.             }
  422.         }
  423.         return $this;
  424.     }
  425. }