src/Entity/User.php line 21

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 Serializable;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. /**
  13.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  14.  * @UniqueEntity("EmailUser",message="Cette email est déjà utilisé")
  15.  * @Vich\Uploadable()
  16.  * @method string getUserIdentifier()*/
  17. class User implements UserInterfaceSerializable
  18. {
  19.     const TypeCompte = [
  20.         //0 => 'Signature',
  21.         => 'parc'
  22.     ];
  23.     /**
  24.      * @ORM\Id()
  25.      * @ORM\GeneratedValue()
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $id;
  29.     /**
  30.      * Nom du user
  31.      * @ORM\Column(type="string", length=255)
  32.      * @Assert\Length(min="1", minMessage="Champ obligatoire")
  33.      */
  34.     private $NomUser;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      * @Assert\Length(min=5,max=255)
  38.      */
  39.     private $EmailUser;
  40.     /**
  41.      * @ORM\Column(type="string", length=255)
  42.      * @Assert\Length(
  43.      *     min=8,
  44.      *     minMessage="Mot de passe courte, au moins 8 caractères"
  45.      * )
  46.      */
  47.     private $PasswordUser;
  48.     /**
  49.      * @Assert\EqualTo(propertyPath="PasswordUser",message="Ne correspond pas au mot de passe")
  50.      */
  51.     private $ConfirmationPassword;
  52.     private $AncienPassword;
  53.     private $AncienPasswordConfirem;
  54.     /**
  55.      * @ORM\Column(type="datetime")
  56.      */
  57.     private $Created_at;
  58.     /**
  59.      * @ORM\Column(type="integer")
  60.      */
  61.     private $TypeCompteUser;
  62.     /**
  63.      * @ORM\Column(type="integer")
  64.      */
  65.     private $EtatCompteUser;
  66.     /**
  67.      * @ORM\Column(type="integer")
  68.      * @Assert\Type(type="integer",message="Champs de type Entier")
  69.      */
  70.     private $NumTelUser;
  71.     /**
  72.      * @ORM\Column(type="string", length=255)
  73.      */
  74.     private $ImageFile;
  75.     /**
  76.      * @ORM\Column(type="string", length=500)
  77.      */
  78.     private $FirebaseToken;
  79.     /**
  80.      * @ORM\Column(type="string", length=500)
  81.      */
  82.     private $textDePrifil;
  83.     /**
  84.      * @var File|null
  85.      * @Assert\File(
  86.      *      maxSize="5242880",
  87.      *      mimeTypes = {
  88.      *          "image/png",
  89.      *          "image/jpeg",
  90.      *          "image/jpg"
  91.      *      },
  92.      *     mimeTypesMessage = "Ce fichier doit être une image")
  93.      * )
  94.      */
  95.     private $fileName;
  96.     /**
  97.      * @var
  98.      */
  99.     private $base64img;
  100.     /**
  101.      * @var
  102.      */
  103.     private $flag;
  104.     /**
  105.      * @ORM\Column(type="datetime")
  106.      */
  107.     private $Connected_at;
  108.     /**
  109.      * @ORM\ManyToOne(targetEntity="App\Entity\Eglise", inversedBy="users")
  110.      */
  111.     private $eglise;
  112.     /**
  113.      * @ORM\ManyToOne(targetEntity="App\Entity\Clan", inversedBy="users")
  114.      */
  115.     private $clan;
  116.     /**
  117.      * @ORM\OneToMany(targetEntity="App\Entity\ImageUser", mappedBy="user")
  118.      */
  119.     private $image;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity="App\Entity\PostLike", mappedBy="user")
  122.      */
  123.     private $likes;
  124.     /**
  125.      * @ORM\OneToMany(targetEntity="App\Entity\PostComment", mappedBy="user")
  126.      */
  127.     private $postComments;
  128.     /**
  129.      * @ORM\OneToMany(targetEntity="App\Entity\PostLikeComment", mappedBy="user")
  130.      */
  131.     private $postLikeComments;
  132.     /**
  133.      * @ORM\OneToMany(targetEntity="App\Entity\Media", mappedBy="user_pub")
  134.      */
  135.     private $media;
  136.     /**
  137.      * @var
  138.      */
  139.     private $codeValidation;
  140.     /**
  141.      * @Assert\EqualTo(propertyPath="codeValidation",message="Code invalide; Réessayer à nouveau")
  142.      */
  143.     private $ConfirCodeValidation;
  144.     /**
  145.      * @ORM\Column(type="string", length=255)
  146.      */
  147.     private $image_file_signature;
  148.     /**
  149.      * @ORM\OneToMany(targetEntity="App\Entity\UserPreference", mappedBy="userPrefere")
  150.      */
  151.     private $userPreferences;
  152.     /**
  153.      * @ORM\OneToMany(targetEntity="App\Entity\UserPreference", mappedBy="userPreferer")
  154.      */
  155.     private $userPreferer;
  156.     /**
  157.      * @ORM\OneToMany(targetEntity="App\Entity\UserLike", mappedBy="userQuiEstLiked")
  158.      */
  159.     private $userQuiEstLiker;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity="App\Entity\UserLike", mappedBy="userQuiLiked")
  162.      */
  163.     private $userQuiLike;
  164.     /**
  165.      * @ORM\Column(type="string", length=255)
  166.      */
  167.     private $roles;
  168.     public function __toString()
  169.     {
  170.         return $this->NomUser;
  171.     }
  172.     public function    __construct()
  173.     {
  174.         $this->Created_at = new \DateTime();
  175.         $this->Connected_at = new \DateTime();
  176.         $this->EtatCompteUser 0;
  177.         $this->textDePrifil 'Je suis, Par ce que nous sommes 🎹🎤🪗🪘🎻🎸';
  178.         $this->ImageFile '0';
  179.         $this->image_file_signature '0';
  180.         $this->image = new ArrayCollection();
  181.         $this->likes = new ArrayCollection();
  182.         //$this->comments = new ArrayCollection();
  183.         $this->postComments = new ArrayCollection();
  184.         $this->postLikeComments = new ArrayCollection();
  185.         $this->media = new ArrayCollection();
  186.         $this->userPreferences = new ArrayCollection();
  187.         $this->userPreferer = new ArrayCollection();
  188.         $this->userQuiEstLiker = new ArrayCollection();
  189.         $this->userQuiLike = new ArrayCollection();
  190.         $this->FirebaseToken '';
  191.         $this->TypeCompteUser '1';
  192.     }
  193.     public function getId(): ?int
  194.     {
  195.         return $this->id;
  196.     }
  197.     public function getId_(): ?int
  198.     {
  199.         return $this->id;
  200.     }
  201.     public function getSlugId(): ?string
  202.     {
  203.        // return (new Slugify())->slugify((string)$this->PasswordUser);
  204.         return $this->PasswordUser;
  205.     }
  206.     public function getNomUser(): ?string
  207.     {
  208.         return $this->NomUser;
  209.     }
  210.     public function setNomUser(string $NomUser): self
  211.     {
  212.         $this->NomUser $NomUser;
  213.         return $this;
  214.     }
  215.     /**
  216.      * @return mixed
  217.      */
  218.     public function getTextDePrifil(): ?string
  219.     {
  220.         return $this->textDePrifil;
  221.     }
  222.     public function setTextDePrifil(String $textDePrifil)
  223.     {
  224.         $this->textDePrifil $textDePrifil;
  225.         return $this;
  226.     }
  227.     public function getFirebaseToken(): ?string
  228.     {
  229.         return $this->FirebaseToken;
  230.     }
  231.     public function setFirebaseToken(String $FirebaseToken)
  232.     {
  233.         $this->FirebaseToken $FirebaseToken;
  234.         return $this;
  235.     }
  236.     public function getEmailUser(): ?string
  237.     {
  238.         return $this->EmailUser;
  239.     }
  240.     public function setEmailUser(string $EmailUser): self
  241.     {
  242.         $this->EmailUser $EmailUser;
  243.         return $this;
  244.     }
  245.     public function getPasswordUser(): ?string
  246.     {
  247.         return $this->PasswordUser;
  248.     }
  249.     public function setPasswordUser(string $PasswordUser): self
  250.     {
  251.         $this->PasswordUser $PasswordUser;
  252.         return $this;
  253.     }
  254.     public function getCreatedAt(): ?\DateTimeInterface
  255.     {
  256.         return $this->Created_at;
  257.     }
  258.     public function setCreatedAt(\DateTimeInterface $Created_at): self
  259.     {
  260.         $this->Created_at $Created_at;
  261.         return $this;
  262.     }
  263.     public function getTypeCompteUser(): ?int
  264.     {
  265.         return $this->TypeCompteUser;
  266.     }
  267.     public function setTypeCompteUser(int $TypeCompteUser): self
  268.     {
  269.         $this->TypeCompteUser $TypeCompteUser;
  270.         return $this;
  271.     }
  272.     public function getEtatCompteUser(): ?int
  273.     {
  274.         return $this->EtatCompteUser;
  275.     }
  276.     public function setEtatCompteUser(int $EtatCompteUser): self
  277.     {
  278.         $this->EtatCompteUser $EtatCompteUser;
  279.         return $this;
  280.     }
  281.     public function getNumTelUser(): ?int
  282.     {
  283.         return $this->NumTelUser;
  284.     }
  285.     public function setNumTelUser(int $NumTelUser): self
  286.     {
  287.         $this->NumTelUser $NumTelUser;
  288.         return $this;
  289.     }
  290.     public function getImageFile()
  291.     {
  292.         return $this->ImageFile;
  293.     }
  294.     public function setImageFile($ImageFile): void
  295.     {
  296.         $this->ImageFile $ImageFile;
  297.     }
  298.     public function getConfirmationPassword()
  299.     {
  300.         return $this->ConfirmationPassword;
  301.     }
  302.     public function setConfirmationPassword($ConfirmationPassword): void
  303.     {
  304.         $this->ConfirmationPassword $ConfirmationPassword;
  305.     }
  306.     public function getFlag()
  307.     {
  308.         return $this->flag;
  309.     }
  310.     public function setFlag($flag): void
  311.     {
  312.         $this->flag $flag;
  313.     }
  314.     public function eraseCredentials(){
  315.     }
  316.     public function getSalt(){
  317.         return null;
  318.     }
  319.     public function getRoles(){
  320.         return [$this->roles];
  321.        // return $this->roles;
  322.     }
  323.     public function setRoles(string $roles): self
  324.     {
  325.         $this->roles $roles;
  326.         return $this;
  327.     }
  328.     public function getPassword(){
  329.         return $this->PasswordUser;
  330.     }
  331.     public function getUsername(){
  332.         return $this->NomUser;
  333.     }
  334.     public function getConnectedAt(): ?\DateTime
  335.     {
  336.         return $this->Connected_at;
  337.     }
  338.     public function setConnectedAt(\DateTime $Connected_at): self
  339.     {
  340.         $this->Connected_at $Connected_at;
  341.         return $this;
  342.     }
  343.     public function getEglise(): ?Eglise
  344.     {
  345.         return $this->eglise;
  346.     }
  347.     public function setEglise(?Eglise $eglise): self
  348.     {
  349.         $this->eglise $eglise;
  350.         return $this;
  351.     }
  352.     public function getClan(): ?Clan
  353.     {
  354.         return $this->clan;
  355.     }
  356.     public function setClan(?Clan $clan): self
  357.     {
  358.         $this->clan $clan;
  359.         return $this;
  360.     }
  361.     /**
  362.      * @return Collection|ImageUser[]
  363.      */
  364.     public function getImage(): Collection
  365.     {
  366.         return $this->image;
  367.     }
  368.     public function addImage(ImageUser $image): self
  369.     {
  370.         if (!$this->image->contains($image)) {
  371.             $this->image[] = $image;
  372.             $image->setUser($this);
  373.         }
  374.         return $this;
  375.     }
  376.     public function removeImage(ImageUser $image): self
  377.     {
  378.         if ($this->image->contains($image)) {
  379.             $this->image->removeElement($image);
  380.             // set the owning side to null (unless already changed)
  381.             if ($image->getUser() === $this) {
  382.                 $image->setUser(null);
  383.             }
  384.         }
  385.         return $this;
  386.     }
  387.     /**
  388.      * @return null|File
  389.      */
  390.     public function getFileName(): ?File
  391.     {
  392.         return $this->fileName;
  393.     }
  394.     /**
  395.      * @param null|File $fileName
  396.      */
  397.     public function setFileName(?File $fileName): void
  398.     {
  399.         $this->fileName $fileName;
  400.     }
  401.     /**
  402.      * @return mixed
  403.      */
  404.     public function getBase64img()
  405.     {
  406.         return $this->base64img;
  407.     }
  408.     /**
  409.      * @param mixed $base64img
  410.      */
  411.     public function setBase64img($base64img): void
  412.     {
  413.         $this->base64img $base64img;
  414.     }
  415.     public function getSlug(): ?string
  416.     {
  417.         //return (new Slugify())->slugify($this->id);
  418.         return $this->id;
  419.     }
  420.     /**
  421.      * String representation of object
  422.      * @link http://php.net/manual/en/serializable.serialize.php
  423.      * @return string the string representation of the object or null
  424.      * @since 5.1.0
  425.      */
  426.     public function serialize()
  427.     {
  428.         return serialize([
  429.             $this->id,
  430.             $this->NomUser,
  431.             $this->EmailUser,
  432.             $this->PasswordUser,
  433.             $this->clan,
  434.             $this->eglise
  435.         ]);
  436.     }
  437.     /**
  438.      * Constructs the object
  439.      * @link http://php.net/manual/en/serializable.unserialize.php
  440.      * @param string $serialized <p>
  441.      * The string representation of the object.
  442.      * </p>
  443.      * @return void
  444.      * @since 5.1.0
  445.      */
  446.     public function unserialize($serialized)
  447.     {
  448.         list(
  449.             $this->id,
  450.             $this->NomUser,
  451.             $this->EmailUser,
  452.             $this->PasswordUser,
  453.             $this->clan,
  454.             $this->eglise
  455.             ) = unserialize($serialized,['allowed_classes' => false]);
  456.     }
  457.     /**
  458.      * @return Collection|PostLike[]
  459.      */
  460.     public function getLikes(): Collection
  461.     {
  462.         return $this->likes;
  463.     }
  464.     public function addLike(PostLike $like): self
  465.     {
  466.         if (!$this->likes->contains($like)) {
  467.             $this->likes[] = $like;
  468.             $like->setUser($this);
  469.         }
  470.         return $this;
  471.     }
  472.     public function removeLike(PostLike $like): self
  473.     {
  474.         if ($this->likes->contains($like)) {
  475.             $this->likes->removeElement($like);
  476.             // set the owning side to null (unless already changed)
  477.             if ($like->getUser() === $this) {
  478.                 $like->setUser(null);
  479.             }
  480.         }
  481.         return $this;
  482.     }
  483.     /**
  484.      * @return Collection|PostComment[]
  485.      */
  486.     public function getPostComments(): Collection
  487.     {
  488.         return $this->postComments;
  489.     }
  490.     public function addPostComment(PostComment $postComment): self
  491.     {
  492.         if (!$this->postComments->contains($postComment)) {
  493.             $this->postComments[] = $postComment;
  494.             $postComment->setUser($this);
  495.         }
  496.         return $this;
  497.     }
  498.     public function removePostComment(PostComment $postComment): self
  499.     {
  500.         if ($this->postComments->contains($postComment)) {
  501.             $this->postComments->removeElement($postComment);
  502.             // set the owning side to null (unless already changed)
  503.             if ($postComment->getUser() === $this) {
  504.                 $postComment->setUser(null);
  505.             }
  506.         }
  507.         return $this;
  508.     }
  509.     /**
  510.      * @return Collection|PostLikeComment[]
  511.      */
  512.     public function getPostLikeComments(): Collection
  513.     {
  514.         return $this->postLikeComments;
  515.     }
  516.     public function addPostLikeComment(PostLikeComment $postLikeComment): self
  517.     {
  518.         if (!$this->postLikeComments->contains($postLikeComment)) {
  519.             $this->postLikeComments[] = $postLikeComment;
  520.             $postLikeComment->setUser($this);
  521.         }
  522.         return $this;
  523.     }
  524.     public function removePostLikeComment(PostLikeComment $postLikeComment): self
  525.     {
  526.         if ($this->postLikeComments->contains($postLikeComment)) {
  527.             $this->postLikeComments->removeElement($postLikeComment);
  528.             // set the owning side to null (unless already changed)
  529.             if ($postLikeComment->getUser() === $this) {
  530.                 $postLikeComment->setUser(null);
  531.             }
  532.         }
  533.         return $this;
  534.     }
  535.     /**
  536.      * @return Collection|Media[]
  537.      */
  538.     public function getMedia(): Collection
  539.     {
  540.         return $this->media;
  541.     }
  542.     public function addMedium(Media $medium): self
  543.     {
  544.         if (!$this->media->contains($medium)) {
  545.             $this->media[] = $medium;
  546.             $medium->setUserPub($this);
  547.         }
  548.         return $this;
  549.     }
  550.     public function removeMedium(Media $medium): self
  551.     {
  552.         if ($this->media->contains($medium)) {
  553.             $this->media->removeElement($medium);
  554.             // set the owning side to null (unless already changed)
  555.             if ($medium->getUserPub() === $this) {
  556.                 $medium->setUserPub(null);
  557.             }
  558.         }
  559.         return $this;
  560.     }
  561.     /**
  562.      * @return mixed
  563.      */
  564.     public function getCodeValidation()
  565.     {
  566.         return $this->codeValidation;
  567.     }
  568.     /**
  569.      * @param mixed $codeValidation
  570.      */
  571.     public function setCodeValidation($codeValidation): void
  572.     {
  573.         $this->codeValidation $codeValidation;
  574.     }
  575.     /**
  576.      * @return mixed
  577.      */
  578.     public function getConfirCodeValidation()
  579.     {
  580.         return $this->ConfirCodeValidation;
  581.     }
  582.     /**
  583.      * @param mixed $ConfirCodeValidation
  584.      */
  585.     public function setConfirCodeValidation($ConfirCodeValidation): void
  586.     {
  587.         $this->ConfirCodeValidation $ConfirCodeValidation;
  588.     }
  589.     public function getImageFileSignature(): ?string
  590.     {
  591.         return $this->image_file_signature;
  592.     }
  593.     public function setImageFileSignature(string $image_file_signature): self
  594.     {
  595.         $this->image_file_signature $image_file_signature;
  596.         return $this;
  597.     }
  598.     /**
  599.      * @return Collection|UserPreference[]
  600.      */
  601.     public function getUserPreferences()
  602.     {
  603.         return $this->id;
  604.     }
  605.     public function addUserPreference(UserPreference $userPreference): self
  606.     {
  607.         if (!$this->userPreferences->contains($userPreference)) {
  608.             $this->userPreferences[] = $userPreference;
  609.             $userPreference->setUserPrefere($this);
  610.         }
  611.         return $this;
  612.     }
  613.     public function removeUserPreference(UserPreference $userPreference): self
  614.     {
  615.         if ($this->userPreferences->contains($userPreference)) {
  616.             $this->userPreferences->removeElement($userPreference);
  617.             // set the owning side to null (unless already changed)
  618.             if ($userPreference->getUserPrefere() === $this) {
  619.                 $userPreference->setUserPrefere(null);
  620.             }
  621.         }
  622.         return $this;
  623.     }
  624.     /**
  625.      * @return Collection|UserPreference[]
  626.      */
  627.     public function getUserPreferer()
  628.     {
  629.         return $this->userPreferer;
  630.     }
  631.     public function addUserPreferer(UserPreference $userPreferer): self
  632.     {
  633.         if (!$this->userPreferer->contains($userPreferer)) {
  634.             $this->userPreferer[] = $userPreferer;
  635.             $userPreferer->setUserPreferer($this);
  636.         }
  637.         return $this;
  638.     }
  639.     public function removeUserPreferer(UserPreference $userPreferer): self
  640.     {
  641.         if ($this->userPreferer->contains($userPreferer)) {
  642.             $this->userPreferer->removeElement($userPreferer);
  643.             // set the owning side to null (unless already changed)
  644.             if ($userPreferer->getUserPreferer() === $this) {
  645.                 $userPreferer->setUserPreferer(null);
  646.             }
  647.         }
  648.         return $this;
  649.     }
  650.     /**
  651.      * Choeur déjà préféré par un user
  652.      * @param User $user
  653.      * @return bool
  654.      */
  655.     public function isPreferedBy(User $user):bool {
  656.         foreach ($this->getUserPreferer() as $prefere){
  657.             if($prefere->getUserPrefere() == $user) return true;
  658.         }
  659.         return false;
  660.     }
  661.     /**
  662.      * @return mixed
  663.      */
  664.     public function getAncienPassword()
  665.     {
  666.         return $this->AncienPassword;
  667.     }
  668.     /**
  669.      * @param mixed $AncienPassword
  670.      */
  671.     public function setAncienPassword($AncienPassword): void
  672.     {
  673.         $this->AncienPassword $AncienPassword;
  674.     }
  675.     /**
  676.      * @return mixed
  677.      */
  678.     public function getAncienPasswordConfirem()
  679.     {
  680.         return $this->AncienPasswordConfirem;
  681.     }
  682.     /**
  683.      * @param mixed $AncienPasswordConfirem
  684.      */
  685.     public function setAncienPasswordConfirem($AncienPasswordConfirem): void
  686.     {
  687.         $this->AncienPasswordConfirem $AncienPasswordConfirem;
  688.     }
  689.     public function __call($name$arguments)
  690.     {
  691.         // TODO: Implement @method string getUserIdentifier()
  692.     }
  693.     /**
  694.      * @return Collection|UserLike[]
  695.      */
  696.     public function getUserQuiEstLiker(): Collection
  697.     {
  698.         return $this->userQuiEstLiker;
  699.     }
  700.     public function addUserQuiEstLiker(UserLike $userLike): self
  701.     {
  702.         if (!$this->userQuiEstLiker->contains($userLike)) {
  703.             $this->userQuiEstLiker[] = $userLike;
  704.             $userLike->setUserQuiEstLiked($this);
  705.         }
  706.         return $this;
  707.     }
  708.     public function removeUserQuiEstLiker(UserLike $userLike): self
  709.     {
  710.         if ($this->userQuiEstLiker->contains($userLike)) {
  711.             $this->userQuiEstLiker->removeElement($userLike);
  712.             // set the owning side to null (unless already changed)
  713.             if ($userLike->getUserQuiEstLiked() === $this) {
  714.                 $userLike->setUserQuiEstLiked(null);
  715.             }
  716.         }
  717.         return $this;
  718.     }
  719.     /**
  720.      * @return Collection|UserLike[]
  721.      */
  722.     public function getUserQuiLike(): Collection
  723.     {
  724.         return $this->userQuiLike;
  725.     }
  726.     public function addUserQuiLike(UserLike $userLike): self
  727.     {
  728.         if (!$this->userQuiLike->contains($userLike)) {
  729.             $this->userQuiLike[] = $userLike;
  730.             $userLike->setUserQuiLiked($this);
  731.         }
  732.         return $this;
  733.     }
  734.     public function removeUserQuiLike(UserLike $userLike): self
  735.     {
  736.         if ($this->userQuiLike->contains($userLike)) {
  737.             $this->userQuiLike->removeElement($userLike);
  738.             if ($userLike->getUserQuiLiked() === $this) {
  739.                 $userLike->setUserQuiLiked(null);
  740.             }
  741.         }
  742.         return $this;
  743.     }
  744.     /**
  745.      * Choeur déjà préféré par un user
  746.      * @param User $user
  747.      * @return bool
  748.      */
  749.     public function isLikedBy(User $user):bool {
  750.         foreach ($this->getUserQuiEstLiker() as $liked){
  751.             if($liked->getUserQuiLiked() == $user) return true;
  752.         }
  753.         return false;
  754.     }
  755. }