src\Entity\User.php line 17

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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Table(name'Users')]
  11. #[ORM\Entity(repositoryClassUserRepository::class)]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. #[ORM\HasLifecycleCallbacks]
  14. class User implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length180uniquetrue)]
  21.     private $email;
  22.     #[ORM\Column(type'json')]
  23.     private $roles = [];
  24.     /**
  25.      * @var string The hashed password
  26.      */
  27.     #[ORM\Column(type'string')]
  28.     private $password;
  29.     #[ORM\Column(type'string'length255)]
  30.     private $nom;
  31.     #[ORM\Column(type'string'length255)]
  32.     private $prenom;
  33.     #[ORM\Column(type'string'length15)]
  34.     private $tel;
  35.     #[ORM\Column(type'integer')]
  36.     private $civilite;
  37.     #[ORM\Column(type'boolean')]
  38.     private $status;
  39.     #[ORM\Column(type'datetime')]
  40.     private $created_at;
  41.     #[ORM\Column(type'datetime'nullabletrue)]
  42.     private $updated_at;
  43.     #[ORM\ManyToOne(targetEntity\App\Entity\Pays::class, inversedBy'users')]
  44.     private $pays;
  45.     #[ORM\OneToMany(targetEntity\App\Entity\Loginattemp::class, mappedBy'user'orphanRemovaltrue)]
  46.     private $loginattemps;
  47.     #[ORM\OneToMany(targetEntity\App\Entity\Tracking::class, mappedBy'user')]
  48.     private $trackings;
  49.     #[ORM\OneToMany(targetEntity\App\Entity\Evenement::class, mappedBy'user')]
  50.     private $evenements;
  51.     #[ORM\OneToMany(targetEntity\App\Entity\News::class, mappedBy'user')]
  52.     private $news;
  53.     #[ORM\OneToMany(targetEntity\App\Entity\Formation::class, mappedBy'user'orphanRemovaltrue)]
  54.     private $formations;
  55.     #[ORM\OneToMany(targetEntity\App\Entity\ChapitreFormation::class, mappedBy'user')]
  56.     private $chapitresFormation;
  57.     #[ORM\OneToMany(targetEntity\App\Entity\FichierFormation::class, mappedBy'user')]
  58.     private $fichierFormations;
  59.     #[ORM\OneToMany(targetEntity\App\Entity\Video::class, mappedBy'user')]
  60.     private $videos;
  61.     #[ORM\OneToMany(targetEntityResetPassword::class, mappedBy'user')]
  62.     private $resetPasswords;
  63.     #[ORM\OneToMany(targetEntityNewsletterTypeUsers::class, mappedBy'user'orphanRemovaltrue)]
  64.     private $newsletterTypeUsers;
  65.     #[ORM\Column(type'string'length255nullabletrue)]
  66.     private $avatar;
  67.     #[ORM\OneToMany(targetEntityPackage::class, mappedBy'user')]
  68.     private $packages;
  69.     #[ORM\OneToMany(targetEntitySouscription::class, mappedBy'user'orphanRemovaltrue)]
  70.     private $souscriptions;
  71.     #[ORM\OneToMany(targetEntityFacture::class, mappedBy'user')]
  72.     private $factures;
  73.     #[ORM\OneToMany(targetEntityUserSubscription::class, mappedBy'user')]
  74.     private $userSubscriptions;
  75.     #[ORM\Column(type'string'length255nullabletrue)]
  76.     private $profil;
  77.     #[ORM\Column(type'string'length255nullabletrue)]
  78.     private $societe;
  79.     #[ORM\Column(type'integer'nullabletrue)]
  80.     private $categorie;
  81.     #[ORM\OneToMany(targetEntityUpdate::class, mappedBy'user')]
  82.     private $updates;
  83.     #[ORM\OneToMany(targetEntityUserBookmark::class, mappedBy'user'orphanRemovaltrue)]
  84.     private $bookmarks;
  85.     const civilites = ['M','Mme','Mlle'],
  86.         civilites_long =['Monsieur','Madame','Mademoiselle'];
  87.     /**
  88.      * User constructor. setting status to true
  89.      */
  90.     function __construct()
  91.     {
  92.         $this->status=true;
  93.         $this->roles = ['ROLE_USER'];
  94.         $this->created_at=new \DateTime();
  95.         $this->loginattemps = new ArrayCollection();
  96.         $this->trackings = new ArrayCollection();
  97.         $this->evenements = new ArrayCollection();
  98.         $this->news = new ArrayCollection();
  99.         $this->formations = new ArrayCollection();
  100.         $this->chapitresFormation = new ArrayCollection();
  101.         $this->fichierFormations = new ArrayCollection();
  102.         $this->videos = new ArrayCollection();
  103.         $this->resetPasswords = new ArrayCollection();
  104.         $this->newsletterTypeUsers = new ArrayCollection();
  105.         $this->packages = new ArrayCollection();
  106.         $this->souscriptions = new ArrayCollection();
  107.         $this->factures = new ArrayCollection();
  108.         $this->userSubscriptions = new ArrayCollection();
  109.         $this->updates = new ArrayCollection();
  110.         $this->bookmarks = new ArrayCollection();
  111.     }
  112.     public function getId(): ?int
  113.     {
  114.         return $this->id;
  115.     }
  116.     public function getEmail(): ?string
  117.     {
  118.         return $this->email;
  119.     }
  120.     public function setEmail(string $email): self
  121.     {
  122.         $this->email $email;
  123.         return $this;
  124.     }
  125.     /**
  126.      * A visual identifier that represents this user.
  127.      *
  128.      * @see UserInterface
  129.      */
  130.     public function getUsername(): string
  131. //    public function getUserIdentifier(): string
  132.     {
  133.         return (string) $this->email;
  134.     }
  135.     /**
  136.      * @see UserInterface
  137.      */
  138.     public function getroles(): array
  139.     {
  140.         $roles=$this->roles;
  141.         $roles[] = 'ROLE_USER';
  142.         return array_unique($roles);
  143.     }
  144.     public function getFullRole(): string
  145.     {
  146.         if(in_array('ROLE_SUPER_ADMIN',$this->roles)){
  147.             return "Super Admin";
  148.         }else if(in_array('ROLE_TECH',$this->roles)){
  149.             return "Technicien";
  150.         }else if(in_array('ROLE_ADMIN',$this->roles)){
  151.             return "Editeur";
  152.         }else return "Membre";
  153.     }
  154.     public function setroles(array $roles): self
  155.     {
  156.         $this->roles $roles;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @see UserInterface
  161.      */
  162.     public function getPassword(): string
  163.     {
  164.         return (string) $this->password;
  165.     }
  166.     public function setPassword(string $password): self
  167.     {
  168.         $this->password $password;
  169.         return $this;
  170.     }
  171.     /**
  172.      * @see UserInterface
  173.      *
  174.      * @return String
  175.      */
  176.     public function getSalt()
  177.     {
  178.         // not needed when using the "bcrypt" algorithm in security.yaml
  179.     }
  180.     /**
  181.      * @see UserInterface
  182.      */
  183.     public function eraseCredentials()
  184.     {
  185.         // If you store any temporary, sensitive data on the user, clear it here
  186.         // $this->plainPassword = null;
  187.     }
  188.     public function getNom(): ?string
  189.     {
  190.         return $this->nom;
  191.     }
  192.     public function setNom(string $nom): self
  193.     {
  194.         $this->nom $nom;
  195.         return $this;
  196.     }
  197.     public function getPrenom(): ?string
  198.     {
  199.         return $this->prenom;
  200.     }
  201.     public function setPrenom(string $prenom): self
  202.     {
  203.         $this->prenom $prenom;
  204.         return $this;
  205.     }
  206.     public function getTel(): ?string
  207.     {
  208.         return $this->tel;
  209.     }
  210.     public function setTel(string $tel): self
  211.     {
  212.         $this->tel $tel;
  213.         return $this;
  214.     }
  215.     public function getCivilite(): ?int
  216.     {
  217.         return $this->civilite;
  218.     }
  219.     public function getFullCivilite(): ?string
  220.     {
  221.         return self::civilites[$this->civilite];
  222.     }
  223.     public function getFullCiviliteLong(): ?string
  224.     {
  225.         return self::civilites_long[$this->civilite];
  226.     }
  227.     public function setCivilite(int $civilite): self
  228.     {
  229.         $this->civilite $civilite;
  230.         return $this;
  231.     }
  232.     public function getStatus(): ?bool
  233.     {
  234.         return $this->status;
  235.     }
  236.     public function setStatus(bool $status): self
  237.     {
  238.         $this->status $status;
  239.         return $this;
  240.     }
  241.     public function getCreatedAt(): ?\DateTimeInterface
  242.     {
  243.         return $this->created_at;
  244.     }
  245.     public function setCreatedAt(\DateTimeInterface $created_at): self
  246.     {
  247.         $this->created_at $created_at;
  248.         return $this;
  249.     }
  250.     public function getUpdatedAt(): ?\DateTimeInterface
  251.     {
  252.         return $this->updated_at;
  253.     }
  254.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  255.     {
  256.         $this->updated_at $updated_at;
  257.         return $this;
  258.     }
  259.     //privates ---------------<
  260.     #[ORM\PrePersist]
  261.     private function setPreCreated(){
  262.         $this->status=true;
  263.         $this->roles 'ROLE_USER';
  264.         $this->created_at=new \DateTime();
  265.     }
  266.     #[ORM\PreUpdate]
  267.     private function setPreUpdate(){
  268.         $this->updated_at=new \DateTime();
  269.     }
  270.     public function getPays(): ?Pays
  271.     {
  272.         return $this->pays;
  273.     }
  274.     public function setPays(?Pays $pays): self
  275.     {
  276.         $this->pays $pays;
  277.         return $this;
  278.     }
  279.     /**
  280.      * @return Collection|Loginattemp[]
  281.      */
  282.     public function getLoginattemps(): Collection
  283.     {
  284.         return $this->loginattemps;
  285.     }
  286.     public function addLoginattemp(Loginattemp $loginattemp): self
  287.     {
  288.         if (!$this->loginattemps->contains($loginattemp)) {
  289.             $this->loginattemps[] = $loginattemp;
  290.             $loginattemp->setUser($this);
  291.         }
  292.         return $this;
  293.     }
  294.     public function removeLoginattemp(Loginattemp $loginattemp): self
  295.     {
  296.         if ($this->loginattemps->contains($loginattemp)) {
  297.             $this->loginattemps->removeElement($loginattemp);
  298.             // set the owning side to null (unless already changed)
  299.             if ($loginattemp->getUser() === $this) {
  300.                 $loginattemp->setUser(null);
  301.             }
  302.         }
  303.         return $this;
  304.     }
  305.     /**
  306.      * @return Collection|Tracking[]
  307.      */
  308.     public function getTrackings(): Collection
  309.     {
  310.         return $this->trackings;
  311.     }
  312.     public function addTracking(Tracking $tracking): self
  313.     {
  314.         if (!$this->trackings->contains($tracking)) {
  315.             $this->trackings[] = $tracking;
  316.             $tracking->setUser($this);
  317.         }
  318.         return $this;
  319.     }
  320.     public function removeTracking(Tracking $tracking): self
  321.     {
  322.         if ($this->trackings->contains($tracking)) {
  323.             $this->trackings->removeElement($tracking);
  324.             // set the owning side to null (unless already changed)
  325.             if ($tracking->getUser() === $this) {
  326.                 $tracking->setUser(null);
  327.             }
  328.         }
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return Collection|Evenement[]
  333.      */
  334.     public function getEvenements(): Collection
  335.     {
  336.         return $this->evenements;
  337.     }
  338.     public function addEvenement(Evenement $evenement): self
  339.     {
  340.         if (!$this->evenements->contains($evenement)) {
  341.             $this->evenements[] = $evenement;
  342.             $evenement->setUser($this);
  343.         }
  344.         return $this;
  345.     }
  346.     public function removeEvenement(Evenement $evenement): self
  347.     {
  348.         if ($this->evenements->contains($evenement)) {
  349.             $this->evenements->removeElement($evenement);
  350.             // set the owning side to null (unless already changed)
  351.             if ($evenement->getUser() === $this) {
  352.                 $evenement->setUser(null);
  353.             }
  354.         }
  355.         return $this;
  356.     }
  357.     /**
  358.      * @return Collection|News[]
  359.      */
  360.     public function getNews(): Collection
  361.     {
  362.         return $this->news;
  363.     }
  364.     public function addNews(News $news): self
  365.     {
  366.         if (!$this->news->contains($news)) {
  367.             $this->news[] = $news;
  368.             $news->setUser($this);
  369.         }
  370.         return $this;
  371.     }
  372.     public function removeNews(News $news): self
  373.     {
  374.         if ($this->news->contains($news)) {
  375.             $this->news->removeElement($news);
  376.             // set the owning side to null (unless already changed)
  377.             if ($news->getUser() === $this) {
  378.                 $news->setUser(null);
  379.             }
  380.         }
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return Collection|Formation[]
  385.      */
  386.     public function getFormations(): Collection
  387.     {
  388.         return $this->formations;
  389.     }
  390.     public function addFormation(Formation $formation): self
  391.     {
  392.         if (!$this->formations->contains($formation)) {
  393.             $this->formations[] = $formation;
  394.             $formation->setUser($this);
  395.         }
  396.         return $this;
  397.     }
  398.     public function removeFormation(Formation $formation): self
  399.     {
  400.         if ($this->formations->contains($formation)) {
  401.             $this->formations->removeElement($formation);
  402.             // set the owning side to null (unless already changed)
  403.             if ($formation->getUser() === $this) {
  404.                 $formation->setUser(null);
  405.             }
  406.         }
  407.         return $this;
  408.     }
  409.     /**
  410.      * @return Collection|ChapitreFormation[]
  411.      */
  412.     public function getChapitresFormation(): Collection
  413.     {
  414.         return $this->chapitresFormation;
  415.     }
  416.     public function addChapitresFormation(ChapitreFormation $chapitresFormation): self
  417.     {
  418.         if (!$this->chapitresFormation->contains($chapitresFormation)) {
  419.             $this->chapitresFormation[] = $chapitresFormation;
  420.             $chapitresFormation->setUser($this);
  421.         }
  422.         return $this;
  423.     }
  424.     public function removeChapitresFormation(ChapitreFormation $chapitresFormation): self
  425.     {
  426.         if ($this->chapitresFormation->contains($chapitresFormation)) {
  427.             $this->chapitresFormation->removeElement($chapitresFormation);
  428.             // set the owning side to null (unless already changed)
  429.             if ($chapitresFormation->getUser() === $this) {
  430.                 $chapitresFormation->setUser(null);
  431.             }
  432.         }
  433.         return $this;
  434.     }
  435.     /**
  436.      * @return Collection|FichierFormation[]
  437.      */
  438.     public function getFichierFormations(): Collection
  439.     {
  440.         return $this->fichierFormations;
  441.     }
  442.     public function addFichierFormation(FichierFormation $fichierFormation): self
  443.     {
  444.         if (!$this->fichierFormations->contains($fichierFormation)) {
  445.             $this->fichierFormations[] = $fichierFormation;
  446.             $fichierFormation->setUser($this);
  447.         }
  448.         return $this;
  449.     }
  450.     public function removeFichierFormation(FichierFormation $fichierFormation): self
  451.     {
  452.         if ($this->fichierFormations->contains($fichierFormation)) {
  453.             $this->fichierFormations->removeElement($fichierFormation);
  454.             // set the owning side to null (unless already changed)
  455.             if ($fichierFormation->getUser() === $this) {
  456.                 $fichierFormation->setUser(null);
  457.             }
  458.         }
  459.         return $this;
  460.     }
  461.     /**
  462.      * @return Collection|Video[]
  463.      */
  464.     public function getVideos(): Collection
  465.     {
  466.         return $this->videos;
  467.     }
  468.     public function addVideo(Video $video): self
  469.     {
  470.         if (!$this->videos->contains($video)) {
  471.             $this->videos[] = $video;
  472.             $video->setUser($this);
  473.         }
  474.         return $this;
  475.     }
  476.     public function removeVideo(Video $video): self
  477.     {
  478.         if ($this->videos->contains($video)) {
  479.             $this->videos->removeElement($video);
  480.             // set the owning side to null (unless already changed)
  481.             if ($video->getUser() === $this) {
  482.                 $video->setUser(null);
  483.             }
  484.         }
  485.         return $this;
  486.     }
  487.     /**
  488.      * @return Collection|ResetPassword[]
  489.      */
  490.     public function getResetPasswords(): Collection
  491.     {
  492.         return $this->resetPasswords;
  493.     }
  494.     public function addResetPassword(ResetPassword $resetPassword): self
  495.     {
  496.         if (!$this->resetPasswords->contains($resetPassword)) {
  497.             $this->resetPasswords[] = $resetPassword;
  498.             $resetPassword->setUser($this);
  499.         }
  500.         return $this;
  501.     }
  502.     public function removeResetPassword(ResetPassword $resetPassword): self
  503.     {
  504.         if ($this->resetPasswords->contains($resetPassword)) {
  505.             $this->resetPasswords->removeElement($resetPassword);
  506.             // set the owning side to null (unless already changed)
  507.             if ($resetPassword->getUser() === $this) {
  508.                 $resetPassword->setUser(null);
  509.             }
  510.         }
  511.         return $this;
  512.     }
  513.     /**
  514.      * @return Collection|NewsletterTypeUsers[]
  515.      */
  516.     public function getNewsletterTypeUsers(): Collection
  517.     {
  518.         return $this->newsletterTypeUsers;
  519.     }
  520.     public function addNewsletterTypeUser(NewsletterTypeUsers $newsletterTypeUser): self
  521.     {
  522.         if (!$this->newsletterTypeUsers->contains($newsletterTypeUser)) {
  523.             $this->newsletterTypeUsers[] = $newsletterTypeUser;
  524.             $newsletterTypeUser->setUser($this);
  525.         }
  526.         return $this;
  527.     }
  528.     public function removeNewsletterTypeUser(NewsletterTypeUsers $newsletterTypeUser): self
  529.     {
  530.         if ($this->newsletterTypeUsers->contains($newsletterTypeUser)) {
  531.             $this->newsletterTypeUsers->removeElement($newsletterTypeUser);
  532.             // set the owning side to null (unless already changed)
  533.             if ($newsletterTypeUser->getUser() === $this) {
  534.                 $newsletterTypeUser->setUser(null);
  535.             }
  536.         }
  537.         return $this;
  538.     }
  539.     public function getAvatar(): ?string
  540.     {
  541.         return $this->avatar;
  542.     }
  543.     public function setAvatar(?string $avatar): self
  544.     {
  545.         $this->avatar $avatar;
  546.         return $this;
  547.     }
  548.     /**
  549.      * @return Collection|Package[]
  550.      */
  551.     public function getPackages(): Collection
  552.     {
  553.         return $this->packages;
  554.     }
  555.     public function addPackage(Package $package): self
  556.     {
  557.         if (!$this->packages->contains($package)) {
  558.             $this->packages[] = $package;
  559.             $package->setUser($this);
  560.         }
  561.         return $this;
  562.     }
  563.     public function removePackage(Package $package): self
  564.     {
  565.         if ($this->packages->contains($package)) {
  566.             $this->packages->removeElement($package);
  567.             // set the owning side to null (unless already changed)
  568.             if ($package->getUser() === $this) {
  569.                 $package->setUser(null);
  570.             }
  571.         }
  572.         return $this;
  573.     }
  574.     /**
  575.      * @return Collection|Souscription[]
  576.      */
  577.     public function getSouscriptions(): Collection
  578.     {
  579.         return $this->souscriptions;
  580.     }
  581.     public function addSouscription(Souscription $souscription): self
  582.     {
  583.         if (!$this->souscriptions->contains($souscription)) {
  584.             $this->souscriptions[] = $souscription;
  585.             $souscription->setUser($this);
  586.         }
  587.         return $this;
  588.     }
  589.     public function removeSouscription(Souscription $souscription): self
  590.     {
  591.         if ($this->souscriptions->contains($souscription)) {
  592.             $this->souscriptions->removeElement($souscription);
  593.             // set the owning side to null (unless already changed)
  594.             if ($souscription->getUser() === $this) {
  595.                 $souscription->setUser(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return Collection|Facture[]
  602.      */
  603.     public function getFactures(): Collection
  604.     {
  605.         return $this->factures;
  606.     }
  607.     public function addFacture(Facture $facture): self
  608.     {
  609.         if (!$this->factures->contains($facture)) {
  610.             $this->factures[] = $facture;
  611.             $facture->setUser($this);
  612.         }
  613.         return $this;
  614.     }
  615.     public function removeFacture(Facture $facture): self
  616.     {
  617.         if ($this->factures->contains($facture)) {
  618.             $this->factures->removeElement($facture);
  619.             // set the owning side to null (unless already changed)
  620.             if ($facture->getUser() === $this) {
  621.                 $facture->setUser(null);
  622.             }
  623.         }
  624.         return $this;
  625.     }
  626.     /**
  627.      * @return Collection|UserSubscription[]
  628.      */
  629.     public function getUserSubscriptions(): Collection
  630.     {
  631.         return $this->userSubscriptions;
  632.     }
  633.     public function addUserSubscription(UserSubscription $userSubscription): self
  634.     {
  635.         if (!$this->userSubscriptions->contains($userSubscription)) {
  636.             $this->userSubscriptions[] = $userSubscription;
  637.             $userSubscription->setUser($this);
  638.         }
  639.         return $this;
  640.     }
  641.     public function removeUserSubscription(UserSubscription $userSubscription): self
  642.     {
  643.         if ($this->userSubscriptions->contains($userSubscription)) {
  644.             $this->userSubscriptions->removeElement($userSubscription);
  645.             // set the owning side to null (unless already changed)
  646.             if ($userSubscription->getUser() === $this) {
  647.                 $userSubscription->setUser(null);
  648.             }
  649.         }
  650.         return $this;
  651.     }
  652.     public function getProfil(): ?string
  653.     {
  654.         return $this->profil;
  655.     }
  656.     public function setProfil(?string $profil): self
  657.     {
  658.         $this->profil $profil;
  659.         return $this;
  660.     }
  661.     public function getSociete(): ?string
  662.     {
  663.         return $this->societe;
  664.     }
  665.     public function setSociete(?string $societe): self
  666.     {
  667.         $this->societe $societe;
  668.         return $this;
  669.     }
  670.     public function getCategorie(): ?int
  671.     {
  672.         return $this->categorie;
  673.     }
  674.     public function setCategorie(?int $categorie): self
  675.     {
  676.         $this->categorie $categorie;
  677.         return $this;
  678.     }
  679.     /**
  680.      * @return Collection|Update[]
  681.      */
  682.     public function getUpdates(): Collection
  683.     {
  684.         return $this->updates;
  685.     }
  686.     public function addUpdate(Update $update): self
  687.     {
  688.         if (!$this->updates->contains($update)) {
  689.             $this->updates[] = $update;
  690.             $update->setUser($this);
  691.         }
  692.         return $this;
  693.     }
  694.     public function removeUpdate(Update $update): self
  695.     {
  696.         if ($this->updates->removeElement($update)) {
  697.             // set the owning side to null (unless already changed)
  698.             if ($update->getUser() === $this) {
  699.                 $update->setUser(null);
  700.             }
  701.         }
  702.         return $this;
  703.     }
  704.     /**
  705.      * @return Collection|UserBookmark[]
  706.      */
  707.     public function getBookmarks(): Collection
  708.     {
  709.         return $this->bookmarks;
  710.     }
  711.     public function addBookmark(UserBookmark $bookmark): self
  712.     {
  713.         if (!$this->bookmarks->contains($bookmark)) {
  714.             $this->bookmarks[] = $bookmark;
  715.             $bookmark->setUser($this);
  716.         }
  717.         return $this;
  718.     }
  719.     public function removeBookmark(UserBookmark $bookmark): self
  720.     {
  721.         if ($this->bookmarks->removeElement($bookmark)) {
  722.             // set the owning side to null (unless already changed)
  723.             if ($bookmark->getUser() === $this) {
  724.                 $bookmark->setUser(null);
  725.             }
  726.         }
  727.         return $this;
  728.     }
  729. }