src/Entity/User.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Stripe\Product;
  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. use Symfony\Component\Serializer\Annotation\MaxDepth;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  14.  *
  15.  * @ORM\HasLifecycleCallbacks()
  16.  *
  17.  * @UniqueEntity("email")
  18.  */
  19. class User implements UserInterfacePasswordAuthenticatedUserInterface
  20. {
  21.     public function __construct()
  22.     {
  23.         $this->articles = new ArrayCollection();
  24.         $this->suggestedArticles = new ArrayCollection();
  25.         $this->articlesViewed = new ArrayCollection();
  26.         $this->userOffers = new ArrayCollection();
  27.         $this->documents = new ArrayCollection();
  28.         $this->userCategories = new ArrayCollection();
  29.         $this->likes = new ArrayCollection();
  30.         $this->users_cart = new ArrayCollection();
  31.         $this->users_favoris = new ArrayCollection();
  32.         $this->user_articles = new ArrayCollection();
  33.     }
  34.     /**
  35.      * @ORM\Id()
  36.      *
  37.      * @ORM\GeneratedValue()
  38.      *
  39.      * @ORM\Column(type="integer")
  40.      */
  41.     private $id;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity="App\Entity\UserCategory", mappedBy="user")
  44.      */
  45.     private $userCategories;
  46.     /**
  47.      * @ORM\Column(type="string", nullable=true, length=180)
  48.      */
  49.     private $pseudo null;
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getPseudo(): ?string
  55.     {
  56.         return $this->pseudo;
  57.     }
  58.     public function setPseudo($pseudo): self
  59.     {
  60.         $this->pseudo $pseudo;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @ORM\Column(type="string", nullable=true)
  65.      */
  66.     private $secteur;
  67.     /**
  68.      * @ORM\Column(type="string", nullable=true)
  69.      */
  70.     private $company;
  71.     /**
  72.      * @ORM\Column(type="string", nullable=true)
  73.      */
  74.     private $fonction;
  75.     /**
  76.      * @ORM\Column(type="string", length=180, unique=true)
  77.      *
  78.      * @Assert\NotBlank
  79.      *
  80.      * @Assert\Email
  81.      */
  82.     private $email;
  83.     /**
  84.      * @var string The hashed password
  85.      *
  86.      * @ORM\Column(type="string", nullable=true)
  87.      *
  88.      * @Assert\NotBlank
  89.      */
  90.     private $password;
  91.     /**
  92.      * @ORM\Column(type="string", length=255, nullable=true)
  93.      */
  94.     private $auth_activation_token;
  95.     /**
  96.      * @ORM\Column(type="string", length=255, nullable=true)
  97.      */
  98.     private $auth_password_token;
  99.     /**
  100.      * @ORM\Column(type="datetime", nullable=true)
  101.      */
  102.     private $activated_at;
  103.     /**
  104.      * @ORM\Column(type="string", nullable=true)
  105.      */
  106.     private $facebook_id;
  107.     /**
  108.      * @ORM\Column(type="string", nullable=true)
  109.      */
  110.     private $google_id;
  111.     /**
  112.      * @ORM\Column(type="string", nullable=true)
  113.      */
  114.     private $linkedin_id;
  115.     /**
  116.      * @ORM\Column(type="string", nullable=true)
  117.      */
  118.     private $stripe_customer_id;
  119.     /**
  120.      * @ORM\Column(type="string", nullable=true)
  121.      */
  122.     private $complement_adresse;
  123.     public function getEmail(): ?string
  124.     {
  125.         return $this->email;
  126.     }
  127.     public function setEmail(string $email): self
  128.     {
  129.         $this->email $email;
  130.         return $this;
  131.     }
  132.     /**
  133.      * A visual identifier that represents this user.
  134.      *
  135.      * @see UserInterface
  136.      */
  137.     public function getUsername(): string
  138.     {
  139.         return (string) $this->email;
  140.     }
  141.     /**
  142.      * @see UserInterface
  143.      */
  144.     public function getRoles(): array
  145.     {
  146.         $roles = [$this->getRole()->getName()];
  147.         $roles[] = 'ROLE_USER';
  148.         if ('ROLE_USER' !== $this->getRole()->getName()) {
  149.             $roles[] = 'ROLE_API';
  150.         }
  151.         return array_unique($roles);
  152.     }
  153.     /**
  154.      * @see UserInterface
  155.      */
  156.     public function getPassword(): ?string
  157.     {
  158.         return (string) $this->password;
  159.     }
  160.     public function setPassword(?string $password): self
  161.     {
  162.         $this->password $password;
  163.         return $this;
  164.     }
  165.     /**
  166.      * @see UserInterface
  167.      */
  168.     public function getSalt()
  169.     {
  170.         // not needed when using the "bcrypt" algorithm in security.yaml
  171.     }
  172.     /**
  173.      * @see UserInterface
  174.      */
  175.     public function eraseCredentials()
  176.     {
  177.         // If you store any temporary, sensitive data on the user, clear it here
  178.         // $this->plainPassword = null;
  179.     }
  180.     public function getAuthActivationToken(): ?string
  181.     {
  182.         return $this->auth_activation_token;
  183.     }
  184.     public function setAuthActivationToken(?string $auth_activation_token): self
  185.     {
  186.         $this->auth_activation_token $auth_activation_token;
  187.         return $this;
  188.     }
  189.     public function getAuthPasswordToken(): ?string
  190.     {
  191.         return $this->auth_password_token;
  192.     }
  193.     public function setAuthPasswordToken(?string $auth_password_token): self
  194.     {
  195.         $this->auth_password_token $auth_password_token;
  196.         return $this;
  197.     }
  198.     public function getActivatedAt(): ?\DateTimeInterface
  199.     {
  200.         return $this->activated_at;
  201.     }
  202.     public function setActivatedAt(?\DateTimeInterface $activated_at): self
  203.     {
  204.         $this->activated_at $activated_at;
  205.         return $this;
  206.     }
  207.     /**
  208.      * @ORM\Column(type="datetime", nullable=false)
  209.      */
  210.     private $created_at;
  211.     /**
  212.      * @ORM\Column(type="datetime", nullable=true)
  213.      */
  214.     private $updated_at null;
  215.     public function getCreatedAt(): \DateTimeInterface
  216.     {
  217.         return $this->created_at;
  218.     }
  219.     public function setCreatedAt(\DateTimeInterface $created_at): self
  220.     {
  221.         $this->created_at $created_at;
  222.         return $this;
  223.     }
  224.     public function getUpdatedAt(): ?\DateTimeInterface
  225.     {
  226.         return $this->updated_at;
  227.     }
  228.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  229.     {
  230.         $this->updated_at $updated_at;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @ORM\PrePersist
  235.      */
  236.     public function setCreatedAtValue()
  237.     {
  238.         $this->setCreatedAt(new \DateTime());
  239.     }
  240.     /**
  241.      * @ORM\PreUpdate
  242.      */
  243.     public function setUpdatedAtValue()
  244.     {
  245.         $this->setUpdatedAt(new \DateTime());
  246.     }
  247.     /**
  248.      * @ORM\Column(type="datetime", nullable=true)
  249.      */
  250.     private $deleted_at;
  251.     public function getDeletedAt(): ?\DateTimeInterface
  252.     {
  253.         return $this->deleted_at;
  254.     }
  255.     public function setDeletedAt(?\DateTimeInterface $deleted_at): self
  256.     {
  257.         $this->deleted_at $deleted_at;
  258.         return $this;
  259.     }
  260.     /**
  261.      * @return mixed
  262.      */
  263.     public function getStripeCustomerId()
  264.     {
  265.         return $this->stripe_customer_id;
  266.     }
  267.     /**
  268.      * @param mixed $stripe_customer_id
  269.      *
  270.      * @return User
  271.      */
  272.     public function setStripeCustomerId($stripe_customer_id)
  273.     {
  274.         $this->stripe_customer_id $stripe_customer_id;
  275.         return $this;
  276.     }
  277.     // Target of a LinkedEntity from UserController (Controller)
  278.     // Target of a OneToMany from Role (Entity)
  279.     /**
  280.      * @ORM\ManyToOne(targetEntity="App\Entity\Role", inversedBy="users")
  281.      *
  282.      * @ORM\JoinColumn(nullable=true)
  283.      *
  284.      * @MaxDepth(1)
  285.      */
  286.     private $role;
  287.     /**
  288.      * @ORM\OneToMany(targetEntity="App\Entity\Article", mappedBy="user")
  289.      */
  290.     private $articles;
  291.     /**
  292.      * @ORM\OneToMany(targetEntity="App\Entity\SuggestedArticle", mappedBy="user")
  293.      */
  294.     private $suggestedArticles;
  295.     /**
  296.      * @ORM\OneToMany(targetEntity="App\Entity\ArticleView", mappedBy="user")
  297.      */
  298.     private $articlesViewed;
  299.     /**
  300.      * @ORM\Column(type="string", length=255, nullable=true)
  301.      */
  302.     private $firstname;
  303.     /**
  304.      * @ORM\Column(type="string", length=255, nullable=true)
  305.      */
  306.     private $lastname;
  307.     /**
  308.      * @ORM\Column(type="string", length=255, nullable=true)
  309.      */
  310.     private $phone;
  311.     /**
  312.      * @ORM\Column(type="string", length=255, nullable=true)
  313.      */
  314.     private $address;
  315.     /**
  316.      * @ORM\Column(type="string", length=255, nullable=true)
  317.      */
  318.     private $zipcode;
  319.     /**
  320.      * @ORM\Column(type="string", length=255, nullable=true)
  321.      */
  322.     private $city;
  323.     /**
  324.      * @ORM\Column(type="string", length=255, nullable=true)
  325.      */
  326.     private $country;
  327.     /**
  328.      * @ORM\Column(type="integer", nullable=true)
  329.      */
  330.     private $legacy_id;
  331.     /**
  332.      * @ORM\Column(type="integer", nullable=true, options={"default": 0})
  333.      */
  334.     private $is_digital_premium 0;
  335.     /**
  336.      * @ORM\OneToMany(targetEntity="App\Entity\UserOffer", mappedBy="user")
  337.      */
  338.     private $userOffers;
  339.     /**
  340.      * @ORM\OneToMany(targetEntity="App\Entity\UserConfidentialDocument", mappedBy="user")
  341.      */
  342.     private $documents;
  343.     /**
  344.      * @ORM\ManyToOne(targetEntity="App\Entity\Media")
  345.      *
  346.      * @ORM\JoinColumn(nullable=true)
  347.      */
  348.     private $avatar;
  349.     /**
  350.      * @ORM\Column(type="text", length=600, nullable=true)
  351.      */
  352.     private $bio;
  353.     /**
  354.      * @ORM\Column(type="string", length=255, nullable=true)
  355.      */
  356.     private $facebook_url;
  357.     /**
  358.      * @ORM\Column(type="string", length=255, nullable=true)
  359.      */
  360.     private $linkedin_url;
  361.     /**
  362.      * @ORM\Column(type="string", length=255, nullable=true)
  363.      */
  364.     private $twitter_url;
  365.     /**
  366.      * @ORM\Column(type="string", length=255, nullable=true)
  367.      */
  368.     private $instagram_url;
  369.     /**
  370.      * @ORM\Column(type="string", length=255, nullable=true)
  371.      */
  372.     private $youtube_url;
  373.     /**
  374.      * @ORM\Column(type="string", length=300, nullable=true)
  375.      */
  376.     private $journey;
  377.     /**
  378.      * @ORM\OneToMany(targetEntity="App\Entity\UserLikes", mappedBy="user", cascade={"persist", "remove"})
  379.      */
  380.     private $likes;
  381.     /**
  382.      * @ORM\OneToMany(targetEntity="App\Entity\Cart", mappedBy="user", cascade={"persist", "remove"})
  383.      */
  384.     private $users_cart;
  385.     /**
  386.      * @ORM\oneToMany(targetEntity="App\Entity\Favoris", mappedBy="user", cascade={"persist", "remove"})
  387.      */
  388.     private $users_favoris;
  389.     /**
  390.      * @ORM\oneToMany(targetEntity="App\Entity\ArticleFavoris", mappedBy="user", cascade={"persist", "remove"})
  391.      */
  392.     private $user_articles;
  393.     public function getRole(): ?Role
  394.     {
  395.         return $this->role;
  396.     }
  397.     public function setRole(?Role $role): self
  398.     {
  399.         $this->role $role;
  400.         return $this;
  401.     }
  402.     /**
  403.      * @return Collection|Article[]
  404.      */
  405.     public function getArticles(): Collection
  406.     {
  407.         return $this->articles;
  408.     }
  409.     public function addArticle(Article $article): self
  410.     {
  411.         if (!$this->articles->contains($article)) {
  412.             $this->articles[] = $article;
  413.             $article->setUser($this);
  414.         }
  415.         return $this;
  416.     }
  417.     public function removeArticle(Article $article): self
  418.     {
  419.         if ($this->articles->contains($article)) {
  420.             $this->articles->removeElement($article);
  421.             // set the owning side to null (unless already changed)
  422.             if ($article->getUser() === $this) {
  423.                 $article->setUser(null);
  424.             }
  425.         }
  426.         return $this;
  427.     }
  428.     /**
  429.      * @return Collection|SuggestedArticle[]
  430.      */
  431.     public function getSuggestedArticles(): Collection
  432.     {
  433.         return $this->suggestedArticles;
  434.     }
  435.     public function addSuggestedArticle(SuggestedArticle $suggestedArticle): self
  436.     {
  437.         if (!$this->suggestedArticles->contains($suggestedArticle)) {
  438.             $this->suggestedArticles[] = $suggestedArticle;
  439.             $suggestedArticle->setUser($this);
  440.         }
  441.         return $this;
  442.     }
  443.     public function removeSuggestedArticle(SuggestedArticle $suggestedArticle): self
  444.     {
  445.         if ($this->suggestedArticles->contains($suggestedArticle)) {
  446.             $this->suggestedArticles->removeElement($suggestedArticle);
  447.             // set the owning side to null (unless already changed)
  448.             if ($suggestedArticle->getUser() === $this) {
  449.                 $suggestedArticle->setUser(null);
  450.             }
  451.         }
  452.         return $this;
  453.     }
  454.     public function hasPrivilege($action)
  455.     {
  456.         if (null === $this->getRole()) {
  457.             return false;
  458.         }
  459.         if ('ROLE_ADMIN' === $this->getRole()->getName()) {
  460.             return true;
  461.         }
  462.         if ('ROLE_USER' === $this->getRole()->getName()) {
  463.             return false;
  464.         }
  465.         if (!\is_array($this->getRole()->getPrivileges())) {
  466.             return false;
  467.         }
  468.         if (\is_array($action)) {
  469.             foreach ($action as $a) {
  470.                 if (!$this->hasPrivilege($a)) {
  471.                     return false;
  472.                 }
  473.             }
  474.             return true;
  475.         }
  476.         return \in_array($action$this->getRole()->getPrivileges(), true);
  477.     }
  478.     public function getFirstname(): ?string
  479.     {
  480.         return $this->firstname;
  481.     }
  482.     public function setFirstname(?string $firstname): self
  483.     {
  484.         $this->firstname $firstname;
  485.         return $this;
  486.     }
  487.     public function getLastname(): ?string
  488.     {
  489.         return $this->lastname;
  490.     }
  491.     public function setLastname(?string $lastname): self
  492.     {
  493.         $this->lastname $lastname;
  494.         return $this;
  495.     }
  496.     public function getPhone(): ?string
  497.     {
  498.         return $this->phone;
  499.     }
  500.     public function setPhone(?string $phone): self
  501.     {
  502.         $this->phone $phone;
  503.         return $this;
  504.     }
  505.     public function getAddress(): ?string
  506.     {
  507.         return $this->address;
  508.     }
  509.     public function setAddress(?string $address): self
  510.     {
  511.         $this->address $address;
  512.         return $this;
  513.     }
  514.     public function getZipcode(): ?string
  515.     {
  516.         return $this->zipcode;
  517.     }
  518.     public function setZipcode(?string $zipcode): self
  519.     {
  520.         $this->zipcode $zipcode;
  521.         return $this;
  522.     }
  523.     public function getCity(): ?string
  524.     {
  525.         return $this->city;
  526.     }
  527.     public function setCity(?string $city): self
  528.     {
  529.         $this->city $city;
  530.         return $this;
  531.     }
  532.     public function getCountry(): ?string
  533.     {
  534.         return $this->country;
  535.     }
  536.     public function setCountry(?string $country): self
  537.     {
  538.         $this->country $country;
  539.         return $this;
  540.     }
  541.     public function getLegacyId(): ?int
  542.     {
  543.         return $this->legacy_id;
  544.     }
  545.     public function setLegacyId(?int $legacy_id): self
  546.     {
  547.         $this->legacy_id $legacy_id;
  548.         return $this;
  549.     }
  550.     /**
  551.      * @ORM\Column(type="integer")
  552.      */
  553.     private $receive_contact_messages 0;
  554.     /**
  555.      * @ORM\OneToOne(targetEntity=Card::class, mappedBy="user", cascade={"persist", "remove"})
  556.      */
  557.     private $card;
  558.     public function getReceiveContactMessages(): int
  559.     {
  560.         return $this->receive_contact_messages;
  561.     }
  562.     public function setReceiveContactMessages(int $receive_contact_messages): self
  563.     {
  564.         $this->receive_contact_messages $receive_contact_messages;
  565.         return $this;
  566.     }
  567.     public function getIsDigitalPremium(): int
  568.     {
  569.         return $this->is_digital_premium;
  570.     }
  571.     public function setIsDigitalPremium(int $is_digital_premium): self
  572.     {
  573.         $this->is_digital_premium $is_digital_premium;
  574.         return $this;
  575.     }
  576.     /**
  577.      * @return Collection|UserOffer[]
  578.      */
  579.     public function getUserOffers(): Collection
  580.     {
  581.         return $this->userOffers;
  582.     }
  583.     public function addUserOffer(UserOffer $userOffer): self
  584.     {
  585.         if (!$this->userOffers->contains($userOffer)) {
  586.             $this->userOffers[] = $userOffer;
  587.             $userOffer->setUser($this);
  588.         }
  589.         return $this;
  590.     }
  591.     public function removeUserOffer(UserOffer $userOffer): self
  592.     {
  593.         if ($this->userOffers->contains($userOffer)) {
  594.             $this->userOffers->removeElement($userOffer);
  595.             // set the owning side to null (unless already changed)
  596.             if ($userOffer->getUser() === $this) {
  597.                 $userOffer->setUser(null);
  598.             }
  599.         }
  600.         return $this;
  601.     }
  602.     /**
  603.      * @return Collection|UserConfidentialDocument[]
  604.      */
  605.     public function getDocuments(): Collection
  606.     {
  607.         return $this->documents;
  608.     }
  609.     public function addDocument(UserConfidentialDocument $document): self
  610.     {
  611.         if (!$this->documents->contains($document)) {
  612.             $this->documents[] = $document;
  613.             $document->setUser($this);
  614.         }
  615.         return $this;
  616.     }
  617.     public function removeDocument(UserConfidentialDocument $document): self
  618.     {
  619.         if ($this->documents->contains($document)) {
  620.             $this->documents->removeElement($document);
  621.             if ($document->getUser() === $this) {
  622.                 $document->setUser(null);
  623.             }
  624.         }
  625.         return $this;
  626.     }
  627.     /**
  628.      * @return mixed
  629.      */
  630.     public function getFacebookId()
  631.     {
  632.         return $this->facebook_id;
  633.     }
  634.     /**
  635.      * @param mixed $facebook_id
  636.      */
  637.     public function setFacebookId($facebook_id): void
  638.     {
  639.         $this->facebook_id $facebook_id;
  640.     }
  641.     /**
  642.      * @return mixed
  643.      */
  644.     public function getGoogleId()
  645.     {
  646.         return $this->google_id;
  647.     }
  648.     /**
  649.      * @param mixed $google_id
  650.      */
  651.     public function setGoogleId($google_id): void
  652.     {
  653.         $this->google_id $google_id;
  654.     }
  655.     /**
  656.      * @return mixed
  657.      */
  658.     public function getLinkedinId()
  659.     {
  660.         return $this->linkedin_id;
  661.     }
  662.     /**
  663.      * @param mixed $linkedin_id
  664.      */
  665.     public function setLinkedinId($linkedin_id): void
  666.     {
  667.         $this->linkedin_id $linkedin_id;
  668.     }
  669.     public function getAvatar(): ?Media
  670.     {
  671.         return $this->avatar;
  672.     }
  673.     public function setAvatar(?Media $avatar): self
  674.     {
  675.         $this->avatar $avatar;
  676.         return $this;
  677.     }
  678.     /**
  679.      * @return mixed
  680.      */
  681.     public function getBio()
  682.     {
  683.         return $this->bio;
  684.     }
  685.     /**
  686.      * @param mixed $bio
  687.      */
  688.     public function setBio($bio): void
  689.     {
  690.         $this->bio $bio;
  691.     }
  692.     /**
  693.      * @return mixed
  694.      */
  695.     public function getFacebookUrl()
  696.     {
  697.         return $this->facebook_url;
  698.     }
  699.     /**
  700.      * @param mixed $facebook_url
  701.      */
  702.     public function setFacebookUrl($facebook_url): void
  703.     {
  704.         $this->facebook_url $facebook_url;
  705.     }
  706.     /**
  707.      * @return mixed
  708.      */
  709.     public function getLinkedinUrl()
  710.     {
  711.         return $this->linkedin_url;
  712.     }
  713.     /**
  714.      * @param mixed $linkedin_url
  715.      */
  716.     public function setLinkedinUrl($linkedin_url): void
  717.     {
  718.         $this->linkedin_url $linkedin_url;
  719.     }
  720.     /**
  721.      * @return mixed
  722.      */
  723.     public function getTwitterUrl()
  724.     {
  725.         return $this->twitter_url;
  726.     }
  727.     /**
  728.      * @param mixed $twitter_url
  729.      */
  730.     public function setTwitterUrl($twitter_url): void
  731.     {
  732.         $this->twitter_url $twitter_url;
  733.     }
  734.     /**
  735.      * @return mixed
  736.      */
  737.     public function getInstagramUrl()
  738.     {
  739.         return $this->instagram_url;
  740.     }
  741.     /**
  742.      * @param mixed $instagram_url
  743.      */
  744.     public function setInstagramUrl($instagram_url): void
  745.     {
  746.         $this->instagram_url $instagram_url;
  747.     }
  748.     /**
  749.      * @return mixed
  750.      */
  751.     public function getJourney()
  752.     {
  753.         return $this->journey;
  754.     }
  755.     /**
  756.      * @param mixed $journey
  757.      */
  758.     public function setJourney($journey): void
  759.     {
  760.         $this->journey $journey;
  761.     }
  762.     /**
  763.      * @return Collection|UserCategory[]|null
  764.      */
  765.     public function getUserCategories(): ?Collection
  766.     {
  767.         return $this->userCategories;
  768.     }
  769.     public function addUserCategory(UserCategory $userCategory): self
  770.     {
  771.         if ($this->userCategories && !$this->userCategories->contains($userCategory)) {
  772.             $this->userCategories[] = $userCategory;
  773.             $userCategory->setUser($this);
  774.         } elseif (!$this->userCategories) {
  775.             $this->userCategories[] = $userCategory;
  776.         }
  777.         return $this;
  778.     }
  779.     public function removeUserCategory(UserCategory $userCategory): self
  780.     {
  781.         if ($this->userCategories->contains($userCategory)) {
  782.             $this->userCategories->removeElement($userCategory);
  783.             // set the owning side to null (unless already changed)
  784.             if ($userCategory->getUser() === $this) {
  785.                 $userCategory->setUser(null);
  786.             }
  787.         }
  788.         return $this;
  789.     }
  790.     public function clearFavoriteCategories(): self
  791.     {
  792.         $this->userCategories null;
  793.         return $this;
  794.     }
  795.     public function showFavoriteCategories()
  796.     {
  797.         $categories = [];
  798.         if ($this->userCategories) {
  799.             foreach ($this->userCategories as $userCategory) {
  800.                 $categories[] = $userCategory->getCategory();
  801.             }
  802.         }
  803.         return $categories;
  804.     }
  805.     /**
  806.      * @return mixed
  807.      */
  808.     public function getSecteur()
  809.     {
  810.         return $this->secteur;
  811.     }
  812.     /**
  813.      * @param mixed $secteur
  814.      */
  815.     public function setSecteur($secteur): void
  816.     {
  817.         $this->secteur $secteur;
  818.     }
  819.     /**
  820.      * @return mixed
  821.      */
  822.     public function getCompany()
  823.     {
  824.         return $this->company;
  825.     }
  826.     /**
  827.      * @param mixed $company
  828.      */
  829.     public function setCompany($company): void
  830.     {
  831.         $this->company $company;
  832.     }
  833.     /**
  834.      * @return mixed
  835.      */
  836.     public function getFonction()
  837.     {
  838.         return $this->fonction;
  839.     }
  840.     /**
  841.      * @param mixed $fonction
  842.      */
  843.     public function setFonction($fonction): void
  844.     {
  845.         $this->fonction $fonction;
  846.     }
  847.     /**
  848.      * @return mixed
  849.      */
  850.     public function getComplementAdresse()
  851.     {
  852.         return $this->complement_adresse;
  853.     }
  854.     /**
  855.      * @param mixed $complement_adresse
  856.      */
  857.     public function setComplementAdresse($complement_adresse): void
  858.     {
  859.         $this->complement_adresse $complement_adresse;
  860.     }
  861.     /**
  862.      * @return ArrayCollection
  863.      */
  864.     public function getLikes(): Collection
  865.     {
  866.         return $this->likes;
  867.     }
  868.     public function addLikes(UserLikes $like): self
  869.     {
  870.         if (!$this->likes->contains($like)) {
  871.             $this->likes[] = $like;
  872.             $like->setUser($this);
  873.         }
  874.         return $this;
  875.     }
  876.     public function removeLikes(UserLikes $like): self
  877.     {
  878.         if ($this->likes->contains($like)) {
  879.             $this->likes->removeElement($like);
  880.             // set the owning side to null (unless already changed)
  881.             if ($like->getUser() === $this) {
  882.                 $like->setUser(null);
  883.             }
  884.         }
  885.         return $this;
  886.     }
  887.     /**
  888.      * @return Collection<int, Cart>
  889.      */
  890.     public function getUsersCart(): Collection
  891.     {
  892.         return $this->users_cart;
  893.     }
  894.     public function hasAddedProductCart($product): bool
  895.     {
  896.         foreach ($this->users_cart as $cart) {
  897.             if (\is_array($product)) {
  898.                 if ($cart->getProduct()->getStripeId() === $product['stripe_id']) {
  899.                     return true;
  900.                 }
  901.             } else {
  902.                 if ($cart->getProduct()->getStripeId() === $product->getStripeId()) {
  903.                     return true;
  904.                 }
  905.             }
  906.         }
  907.         return false;
  908.     }
  909.     public function hasAddedProductCardCheck($product): bool
  910.     {
  911.         if (null !== $this->getCard()) {
  912.             foreach ($this->getCard()->getItems() as $cart) {
  913.                 if (\is_array($product)) {
  914.                     if ($cart->getMagazines()->getId() === $product['product_database_id']) {
  915.                         return true;
  916.                     }
  917.                     if ($cart->getMagazines()->getStripeId() === $product['stripe_id']) {
  918.                         return true;
  919.                     }
  920.                 }
  921.             }
  922.         }
  923.         return false;
  924.     }
  925.     /**
  926.      * @return Collection<int, Favoris>
  927.      */
  928.     public function getUsersFavoris(): Collection
  929.     {
  930.         return $this->users_favoris;
  931.     }
  932.     public function hasAddedProductFavorite($product): bool
  933.     {
  934.         foreach ($this->users_favoris as $favoris) {
  935.             if ($product instanceof StripeProduct) {
  936.                 if ($favoris->getProduct()->getStripeId() === $product->getStripeId()) {
  937.                     return true;
  938.                 }
  939.             } elseif (\is_array($product)) {
  940.                 if ($favoris->getProduct()->getStripeId() === $product['stripe_id']) {
  941.                     return true;
  942.                 }
  943.             }
  944.         }
  945.         return false;
  946.     }
  947.     /**
  948.      * @return Collection<int, ArticleFavoris>
  949.      */
  950.     public function getArticleFavorites(): Collection
  951.     {
  952.         return $this->user_articles;
  953.     }
  954.     public function hasAddedArticleFavorite($article): bool
  955.     {
  956.         foreach ($this->user_articles as $favoris) {
  957.             if ($article instanceof Article) {
  958.                 if ($favoris->getArticle()->getId() === $article->getId()) {
  959.                     return true;
  960.                 }
  961.             } elseif (\is_array($article)) {
  962.                 if ($favoris->getArticle()->getId() === $article['id']) {
  963.                     return true;
  964.                 }
  965.             }
  966.         }
  967.         return false;
  968.     }
  969.     public function getDisplayName(int $maxChars 0): ?string
  970.     {
  971.         $fullName '';
  972.         if ($this->firstname) {
  973.             $fullName $this->firstname.' '.$this->lastname;
  974.         } elseif ($this->pseudo) {
  975.             $fullName $this->pseudo;
  976.         } else {
  977.             $fullName $this->email;
  978.         }
  979.         if ($maxChars && \mb_strlen($fullName) > $maxChars) {
  980.             $fullName trim(mb_substr($fullName0$maxChars)).'...';
  981.         }
  982.         return ucfirst($fullName);
  983.     }
  984.     public function getCard(): ?Card
  985.     {
  986.         return $this->card;
  987.     }
  988.     public function setCard(Card $card): self
  989.     {
  990.         // set the owning side of the relation if necessary
  991.         if ($card->getUser() !== $this) {
  992.             $card->setUser($this);
  993.         }
  994.         $this->card $card;
  995.         return $this;
  996.     }
  997.     /**
  998.      * @return mixed
  999.      */
  1000.     public function getYoutubeUrl()
  1001.     {
  1002.         return $this->youtube_url;
  1003.     }
  1004.     /**
  1005.      * @param mixed $youtube_url
  1006.      */
  1007.     public function setYoutubeUrl($youtube_url): void
  1008.     {
  1009.         $this->youtube_url $youtube_url;
  1010.     }
  1011. }