src/Entity/User.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\Company;
  5. use App\Entity\Person;
  6. use App\Entity\Town;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. // /**
  15. //  * User
  16. //  * @ORM\Table(name="userrv")
  17. //  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  18. //  * @ORM\InheritanceType("JOINED")
  19. //  * @ORM\DiscriminatorColumn(name="discr", type="string")
  20. //  * @ORM\DiscriminatorMap({"user" = "User", "person" = "Person","company" = "Company","town" = "Town" })
  21. //  */
  22. #[ORM\Table(name"userrv")]
  23. #[ORM\Entity(repositoryClass"App\Repository\UserRepository")]
  24. #[ORM\InheritanceType("JOINED")]
  25. #[ORM\DiscriminatorColumn(name"discr"type"string")]
  26. #[ORM\DiscriminatorMap(["user" => User::class, "person" => Person::class, "company" => Company::class, "town" => Town::class])]
  27. class User implements UserInterface
  28. {
  29.     // /**
  30.     //  * @var int
  31.     //  *
  32.     //  * @ORM\Column(name="id", type="integer", unique=true )
  33.     //  * @ORM\Id
  34.     //  * @ORM\GeneratedValue(strategy="AUTO")
  35.     //  */
  36.     #[ORM\Column(name"id"type"integer"uniquetrue)]
  37.     #[ORM\Id]
  38.     #[ORM\GeneratedValue(strategy"AUTO")]
  39.     #[Groups(['login'])]
  40.     protected $id;
  41.     // /**
  42.     //  * @var int
  43.     //  *
  44.     //  * @ORM\Column(name="gaeaUserId", type="integer", unique=true, nullable=true)
  45.     //  */
  46.     #[ORM\Column(name"gaeaUserId"type"integer"uniquetruenullabletrue)]
  47.     #[Groups(['login'])]
  48.     private $gaeaUserId;
  49.     //  * NE PAS LE SUPPRIMER DE LA TABLE DANS LA BDD, sinon aura l'exception getUserIdentifier : expected string, null returned quand on se login
  50.     #[ORM\Column(name"username"type"string"length255nullabletrue)]
  51.     #[Groups(['login'])]
  52.     private $username;
  53.     /**
  54.      * @var string
  55.      */
  56.     private $email;
  57.     /**
  58.      * @var string
  59.      */
  60.     private $password;
  61.     #[ORM\Column(type"string"length50)]
  62.     #[Groups(['login'])]
  63.     protected $role;
  64.     #[ORM\Column(name"token"type"string"length255nullablefalse)]
  65.     #[Groups(['login'])]
  66.     protected $token;
  67.     #[ORM\Column(name"emailValidated"type"boolean")]
  68.     protected $emailValidated;
  69.     #[ORM\Column(type"boolean")]
  70.     #[Groups(['login'])]
  71.     protected $actived;
  72.     /**
  73.      * @var \DateTime
  74.      */
  75.     #[ORM\Column(name'inscription_date'type'date'nullabletrue)]
  76.     #[Groups(['login'])]
  77.     protected $inscriptiondate;
  78.     /**
  79.      * @var string
  80.      */
  81.     private $discr;
  82.     /**
  83.      * @return string
  84.      */
  85.     public function getgaeaUserId()
  86.     {
  87.         return $this->gaeaUserId;
  88.     }
  89.     /**
  90.      * @param string $username
  91.      */
  92.     public function setgaeaUserId($gaeaUserId)
  93.     {
  94.         $this->gaeaUserId $gaeaUserId;
  95.     }
  96.     /**
  97.      * @return string
  98.      */
  99.     public function getUsername()
  100.     {
  101.         return $this->username;
  102.     }
  103.     /**
  104.      * A visual identifier that represents this user.
  105.      *
  106.      * @see UserInterface
  107.      */
  108.     public function getUserIdentifier(): string
  109.     {
  110.         return (string) $this->gaeaUserId;
  111.     }
  112.     /**
  113.      * @param string $username
  114.      */
  115.     public function setUsername($username)
  116.     {
  117.         $this->username $username;
  118.     }
  119.     /**
  120.      * @return string
  121.      */
  122.     public function getEmail()
  123.     {
  124.         return $this->email;
  125.     }
  126.     /**
  127.      * @param string $email
  128.      */
  129.     public function setEmail($email)
  130.     {
  131.         $this->email $email;
  132.     }
  133.     /**
  134.      * @return string
  135.      */
  136.     public function getPassword()
  137.     {
  138.         return $this->password;
  139.     }
  140.     /**
  141.      * @param string $password
  142.      */
  143.     public function setPassword($password)
  144.     {
  145.         $this->password $password;
  146.     }
  147.     /**
  148.      * @return mixed
  149.      */
  150.     public function getRole()
  151.     {
  152.         return $this->role;
  153.     }
  154.     /**
  155.      * @param mixed $role
  156.      */
  157.     public function setRole($role)
  158.     {
  159.         $this->role $role;
  160.     }
  161.     /**
  162.      * @return string
  163.      */
  164.     public function getToken()
  165.     {
  166.         return $this->token;
  167.     }
  168.     /**
  169.      * @param string $token
  170.      */
  171.     public function setToken($token)
  172.     {
  173.         $this->token $token;
  174.     }
  175.     /**
  176.      * @return bool
  177.      */
  178.     public function isEmailValidated()
  179.     {
  180.         return $this->emailValidated;
  181.     }
  182.     /**
  183.      * @param bool $emailValidated
  184.      */
  185.     public function setEmailValidated($emailValidated)
  186.     {
  187.         $this->emailValidated $emailValidated;
  188.     }
  189.     /**
  190.      * @return bool
  191.      */
  192.     public function isActived()
  193.     {
  194.         return $this->actived;
  195.     }
  196.     /**
  197.      * @return bool
  198.      */
  199.     public function getActived()
  200.     {
  201.         return $this->actived;
  202.     }
  203.     /**
  204.      * @param bool $actived
  205.      */
  206.     public function setActived($actived)
  207.     {
  208.         $this->actived $actived;
  209.     }
  210.     public function getSalt()
  211.     {
  212.         return null;
  213.     }
  214.     public function eraseCredentials()
  215.     {
  216.         return null;
  217.     }
  218.     public function getRoles()
  219.     {
  220.         return [$this->getRole()];
  221.     }
  222.     /**
  223.      * @return int
  224.      */
  225.     public function getId()
  226.     {
  227.         return $this->id;
  228.     }
  229.     /**
  230.      * @param int $id
  231.      */
  232.     public function setId($id)
  233.     {
  234.         $this->id $id;
  235.     }
  236.     /**
  237.      * @return \DateTime
  238.      */
  239.     public function getInscriptiondate()
  240.     {
  241.         return $this->inscriptiondate;
  242.     }
  243.     /**
  244.      * @param \DateTime $inscriptiondate
  245.      */
  246.     public function setInscriptiondate($inscriptiondate)
  247.     {
  248.         $this->inscriptiondate $inscriptiondate;
  249.     }
  250.     ////////////////////////////////////////
  251.     // /**
  252.     //  * @ORM\ManyToMany(targetEntity="Company")
  253.     //  * @ORM\JoinTable (name="fav_company")
  254.     //  */
  255.     #[ORM\ManyToMany(targetEntity"Company")]
  256.     #[ORM\JoinTable(name"fav_company")]
  257.     private $companyfavs;
  258.     // /**
  259.     //  * @ORM\OneToMany(targetEntity="ProductFav", mappedBy="user", orphanRemoval=true, cascade={"persist", "remove", "merge"})
  260.     //  */
  261.     #[ORM\OneToMany(targetEntity"ProductFav"mappedBy"user"orphanRemovaltruecascade: ["persist""remove""merge"])]
  262.     private $productFavUsers;
  263.     // /**
  264.     //  *
  265.     //  * @ORM\OneToMany(targetEntity="App\Entity\Friendship", mappedBy="friend", fetch="EAGER")
  266.     //  */
  267.     #[ORM\OneToMany(targetEntity"Friendship"mappedBy"friend"fetch"EAGER")]
  268.     private $friendsWithMe;
  269.     // /**
  270.     //  * @var array
  271.     //  *
  272.     //  * @ORM\OneToMany(targetEntity="App\Entity\Friendship", mappedBy="user", fetch="EAGER")
  273.     //  */
  274.     #[ORM\OneToMany(targetEntity"Friendship"mappedBy"user"fetch"EAGER")]
  275.     private $myFriends;
  276.     // /**
  277.     //  * @ORM\OneToMany(targetEntity="CompanyFav", mappedBy="user")
  278.     //  */
  279.     #[ORM\OneToMany(targetEntity"CompanyFav"mappedBy"user")]
  280.     private $companyFavUsers;
  281.     // /**
  282.     //  * @ORM\OneToMany(targetEntity="Notification", mappedBy="owner")
  283.     //  */
  284.     #[ORM\OneToMany(targetEntity"Notification"mappedBy"owner")]
  285.     private $notifications;
  286.     public function _construct()
  287.     {
  288.         $this->companyfavs = new ArrayCollection();
  289.         $this->companyFavUsers = new ArrayCollection();
  290.         $this->productFavUsers = new ArrayCollection();
  291.         $this->friendsWithMe = new ArrayCollection();
  292.         $this->myFriends = new ArrayCollection();
  293.         $this->notifications = new ArrayCollection();
  294.     }
  295.     public function addCompanyFavs(Company $company)
  296.     {
  297.         if ($this->companyfavs->contains($company)) {
  298.             return;
  299.         }
  300.         $this->companyfavs[] = $company;
  301.     }
  302.     public function getCompanyFavs()
  303.     {
  304.         return $this->companyfavs;
  305.     }
  306.     public function deleteCompanyFavs($company)
  307.     {
  308.         return $this->companyfavs->removeElement($company);
  309.     }
  310.     public function getDiscr(): ?string
  311.     {
  312.         return $this->discr;
  313.     }
  314.     public function setDiscr(string $discr)
  315.     {
  316.         $this->discr $discr;
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return Collection|ProductFav[]
  321.      */
  322.     public function getProductFavUsers(): Collection
  323.     {
  324.         return $this->productFavUsers;
  325.     }
  326.     public function addProductFav(ProductFav $productFav): self
  327.     {
  328.         if (!$this->productFavUsers->contains($productFav)) {
  329.             $this->productFavUsers[] = $productFav;
  330.             $productFav->setUser($this);
  331.         }
  332.         return $this;
  333.     }
  334.     public function removeProductFav(ProductFav $possession): self
  335.     {
  336.         if ($this->possession->removeElement($possession)) {
  337.             // set the owning side to null (unless already changed)
  338.             if ($possession->getUser() === $this) {
  339.                 $possession->setUser(null);
  340.             }
  341.         }
  342.         return $this;
  343.     }
  344.     /**
  345.      * @return Collection|Notification[]
  346.      */
  347.     public function getNotifications(): Collection
  348.     {
  349.         return $this->notifications;
  350.     }
  351.     public function addNotification(Notification $notification): self
  352.     {
  353.         if (!$this->notifications->contains($notification)) {
  354.             $this->notifications[] = $notification;
  355.             $notification->setOwner($this);
  356.         }
  357.         return $this;
  358.     }
  359.     public function removeNotification(Notification $notification): self
  360.     {
  361.         if ($this->notifications->removeElement($notification)) {
  362.             // set the owning side to null (unless already changed)
  363.             if ($notification->getOwner() === $this) {
  364.                 $notification->setOwner(null);
  365.             }
  366.         }
  367.         return $this;
  368.     }
  369.     /**
  370.      * @return array
  371.      */
  372.     public function getFriendsWithMe()
  373.     {
  374.         return $this->friendsWithMe;
  375.     }
  376.     /**
  377.      * @param array $friendsWithMe
  378.      */
  379.     public function setFriendsWithMe(array $friendsWithMe): void
  380.     {
  381.         $this->friendsWithMe $friendsWithMe;
  382.     }
  383.     /**
  384.      * @return array
  385.      */
  386.     public function getMyFriends()
  387.     {
  388.         return $this->myFriends;
  389.     }
  390.     /**
  391.      * @param array $myFriends
  392.      */
  393.     public function setMyFriends(array $myFriends): void
  394.     {
  395.         $this->myFriends $myFriends;
  396.     }
  397.     /**
  398.      * @return mixed
  399.      */
  400.     public function getCompanyFavUsers()
  401.     {
  402.         return $this->companyFavUsers;
  403.     }
  404.     /**
  405.      * @param mixed $companyFavUsers
  406.      */
  407.     public function setCompanyFavUsers($companyFavUsers): void
  408.     {
  409.         $this->companyFavUsers $companyFavUsers;
  410.     }
  411.     // /**
  412.     //  * @var boolean
  413.     //  *
  414.     //  * @ORM\Column(name="connected", type="boolean", nullable=true)
  415.     //  */
  416.     #[ORM\Column(name"connected"type"boolean"nullabletrue)]
  417.     private $connected;
  418.     // /**
  419.     //  * @ORM\Column(type="string", length=255)
  420.     //  */
  421.     #[ORM\Column(type"string"length255)]
  422.     #[Groups(['company'])]
  423.     protected $firstname;
  424.     // /**
  425.     //  * @ORM\Column(type="string", length=255)
  426.     //  */
  427.     #[ORM\Column(type"string"length255)]
  428.     #[Groups(['company'])]
  429.     protected $lastname;
  430.     // /**
  431.     //  * @ORM\OneToMany(targetEntity=UserPreference::class, mappedBy="user")
  432.     //  */
  433.     #[ORM\OneToMany(targetEntityUserPreference::class, mappedBy"user")]
  434.     private $userPreferences;
  435.     // /**
  436.     //  * @ORM\OneToMany(targetEntity=FavoriteCategory::class, mappedBy="user", orphanRemoval=true)
  437.     //  */
  438.     #[ORM\OneToMany(targetEntityFavoriteCategory::class, mappedBy"user"orphanRemovaltrue)]
  439.     private $favoriteCategories;
  440.     // /**
  441.     //  * @ORM\OneToMany(targetEntity=FavoriteCompany::class, mappedBy="user", orphanRemoval=true)
  442.     //  */
  443.     #[ORM\OneToMany(targetEntityFavoriteCompany::class, mappedBy"company"orphanRemovaltrue)]
  444.     private $favoriteCompanies;
  445.     public function __construct()
  446.     {
  447.         $this->userPreferences = new ArrayCollection();
  448.         $this->favoriteCategories = new ArrayCollection();
  449.         $this->favoriteCompanies = new ArrayCollection();
  450.     }
  451.     // /**
  452.     //  * @ORM\OneToMany(targetEntity=Newsletter::class, mappedBy="gaeaUserNewsletter", orphanRemoval=true)
  453.     //  */
  454.     
  455.     // private $gaeaUserNewsletter;
  456.     // public function __construct()
  457.     // {
  458.     //     $this->gaeaUserNewsletter = new ArrayCollection();
  459.     // }
  460.     /**
  461.      * @return bool
  462.      */
  463.     public function isConnected(): ?bool
  464.     {
  465.         return $this->connected;
  466.     }
  467.     // /**
  468.     //  * @param bool $connected
  469.     //  */
  470.     public function setConnected(bool $connected): void
  471.     {
  472.         $this->connected $connected;
  473.     }
  474.     public function getLastname(): ?string
  475.     {
  476.         return $this->lastname;
  477.     }
  478.     public function setLastname(string $lastname): self
  479.     {
  480.         $this->lastname $lastname;
  481.         return $this;
  482.     }
  483.     public function getFirstname(): ?string
  484.     {
  485.         return $this->firstname;
  486.     }
  487.     public function setFirstname(string $firstname): self
  488.     {
  489.         $this->firstname $firstname;
  490.         return $this;
  491.     }
  492.     /**
  493.      * @return Collection|UserPreference[]
  494.      */
  495.     public function getUserPreferences(): Collection
  496.     {
  497.         return $this->userPreferences;
  498.     }
  499.     public function addUserPreference(UserPreference $userPreference): self
  500.     {
  501.         if (!$this->userPreferences->contains($userPreference)) {
  502.             $this->userPreferences[] = $userPreference;
  503.             $userPreference->setUser($this);
  504.         }
  505.         return $this;
  506.     }
  507.     public function removeUserPreference(UserPreference $userPreference): self
  508.     {
  509.         if ($this->userPreferences->removeElement($userPreference)) {
  510.             // set the owning side to null (unless already changed)
  511.             if ($userPreference->getUser() === $this) {
  512.                 $userPreference->setUser(null);
  513.             }
  514.         }
  515.         return $this;
  516.     }
  517.     /**
  518.      * @return Collection|FavoriteCategory[]
  519.      */
  520.     public function getFavoriteCategories(): Collection
  521.     {
  522.         return $this->favoriteCategories;
  523.     }
  524.     public function addFavoriteCategory(FavoriteCategory $favoriteCategory): self
  525.     {
  526.         if (!$this->favoriteCategories->contains($favoriteCategory)) {
  527.             $this->favoriteCategories[] = $favoriteCategory;
  528.             $favoriteCategory->setUser($this);
  529.         }
  530.         return $this;
  531.     }
  532.     public function removeFavoriteCategory(FavoriteCategory $favoriteCategory): self
  533.     {
  534.         if ($this->favoriteCategories->removeElement($favoriteCategory)) {
  535.             // set the owning side to null (unless already changed)
  536.             if ($favoriteCategory->getUser() === $this) {
  537.                 $favoriteCategory->setUser(null);
  538.             }
  539.         }
  540.         return $this;
  541.     }
  542.     /**
  543.      * @return Collection|FavoriteCompany[]
  544.      */
  545.     public function getFavoriteCompanies(): Collection
  546.     {
  547.         return $this->favoriteCompanies;
  548.     }
  549.     public function addFavoriteCompanies(FavoriteCompany $favoriteCompany): self
  550.     {
  551.         if (!$this->favoriteCompanies->contains($favoriteCompany)) {
  552.             $this->favoriteCompanies[] = $favoriteCompany;
  553.             $favoriteCompany->setUser($this);
  554.         }
  555.         return $this;
  556.     }
  557.     public function removeFavoriteCompanies(FavoriteCompany $favoriteCompany): self
  558.     {
  559.         if ($this->favoriteCompanies->removeElement($favoriteCompany)) {
  560.             // set the owning side to null (unless already changed)
  561.             if ($favoriteCompany->getUser() === $this) {
  562.                 $favoriteCompany->setUser(null);
  563.             }
  564.         }
  565.         return $this;
  566.     }
  567.     // public function getX(): ?string
  568.     // {
  569.     //     return $this->x;
  570.     // }
  571.     // public function setX(string $x): self
  572.     // {
  573.     //     $this->x = $x;
  574.     //     return $this;
  575.     // }
  576. }