src/Entity/User.php line 12

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 Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. #[ORM\Entity(repositoryClass\App\Repository\UserRepository::class)]
  9. class User implements UserInterfacePasswordAuthenticatedUserInterface\Stringable
  10. {
  11.   #[ORM\Id]
  12.   #[ORM\GeneratedValue]
  13.   #[ORM\Column(type'integer')]
  14.   private ?int $id 0;
  15.   #[ORM\Column(type'string'length255nullabletrue)]
  16.   private ?string $emailnull;
  17.   #[ORM\Column(type'string'length255nullabletrue)]
  18.   private ?string $first_namenull;
  19.   #[ORM\Column(type'string'length255nullabletrue)]
  20.   private ?string $last_namenull;
  21.   #[ORM\Column(type'string'length255nullabletrue)]
  22.   private ?string $phone_numbernull;
  23.   #[ORM\Column(type'datetime'nullabletrue)]
  24.   private mixed $created_at;
  25.   #[ORM\Column(type'datetime'nullabletrue)]
  26.   private mixed $updated_at;
  27.   #[ORM\Column(type'integer'nullabletrue)]
  28.   private int $term_version;
  29.   #[ORM\Column(type'integer'nullabletrue)]
  30.   private mixed $font_size;
  31.   #[ORM\Column(type'string'length255nullabletrue)]
  32.   private ?string $font_familynull;
  33.   #[ORM\Column(type'integer'nullabletrue)]
  34.   private mixed $dark_mode null;
  35.   #[ORM\OneToMany(targetEntity\App\Entity\Post::class, mappedBy'created_by')]
  36.   private mixed $created_posts;
  37.   #[ORM\OneToMany(targetEntity\App\Entity\Post::class, mappedBy'updated_by')]
  38.   private mixed $updated_posts;
  39.   #[ORM\Column(name'password'type'string'length255nullabletrue)]
  40.   private ?string $password null;
  41.   #[ORM\Column(type'string'length255nullabletrue)]
  42.   private ?string $rolenull;
  43.   #[ORM\ManyToOne(targetEntity\App\Entity\TargetPublic::class, inversedBy'users')]
  44.   #[ORM\JoinColumn(onDelete'SET NULL')]
  45.   private mixed $public;
  46.   #[ORM\OneToMany(targetEntity\App\Entity\Post::class, mappedBy'edit_user'cascade: ['remove'])]
  47.   private mixed $posts;
  48.   #[ORM\OneToMany(targetEntity\App\Entity\PostLog::class, mappedBy'user'cascade: ['remove'])]
  49.   private mixed $postLogs;
  50.   #[ORM\OneToMany(targetEntity\App\Entity\AuthToken::class, mappedBy'user'cascade: ['remove'])]
  51.   private mixed $tokens;
  52.   #[ORM\Column(type'string'length255nullabletrue)]
  53.   private ?string $token_resetnull;
  54.   #[ORM\Column(type'boolean')]
  55.   private ?bool $active true;
  56.   #[ORM\Column(type'string'length255nullabletrue)]
  57.   private ?string $token_activationnull;
  58.   #[ORM\ManyToMany(targetEntity\App\Entity\Post::class, inversedBy'users')]
  59.   private mixed $favoris;
  60.   #[ORM\ManyToMany(targetEntity\App\Entity\Topic::class, inversedBy'users')]
  61.   private mixed $thematiques;
  62.   #[ORM\ManyToMany(targetEntity\App\Entity\Territory::class, inversedBy'users')]
  63.   private mixed $territoires;
  64.   #[ORM\Column(type'boolean'nullabletrue)]
  65.   private ?bool $private_posts_only;
  66.   #[ORM\OneToMany(targetEntityIncident::class, mappedBy'user')]
  67.   private mixed $incidents;
  68.   public function __construct()
  69.   {
  70.     $this->created_posts = new ArrayCollection();
  71.     $this->updated_posts = new ArrayCollection();
  72.     $this->posts = new ArrayCollection();
  73.     $this->postLogs = new ArrayCollection();
  74.     $this->tokens = new ArrayCollection();
  75.     $this->favoris = new ArrayCollection();
  76.     $this->thematiques = new ArrayCollection();
  77.     $this->territoires = new ArrayCollection();
  78.     $this->incidents = new ArrayCollection();
  79.   }
  80.   public function getPassword(): ?string
  81.   {
  82.     return $this->password;
  83.   }
  84.   public function setPassword(string $password): self
  85.   {
  86.     $this->password $password;
  87.     return $this;
  88.   }
  89.   public function getRoles(): array
  90.   {
  91.     if ($this->role == 'admin') {
  92.       return ['ROLE_ADMIN'];
  93.     } else if ($this->role == 'superadmin') {
  94.       return ['ROLE_SUPERADMIN'];
  95.     } else if ($this->role == 'lenordadmin') {
  96.       return ['ROLE_LENORDADMIN'];
  97.     } else if ($this->role == 'redacteur') {
  98.       return ['ROLE_REDACTEUR'];
  99.     } else if ($this->role == 'lecteur') {
  100.       return ["ROLE_LECTEUR"];
  101.     } else if ($this->role == 'agent') {
  102.       return ["ROLE_AGENT"];
  103.     } else if ($this->role == 'public') {
  104.       return ["ROLE_PUBLIC"];
  105.     } else if ($this->role == 'presse') {
  106.       return ["ROLE_PRESSE"];
  107.     } else if ($this->role == 'vip') {
  108.       return ["ROLE_VIP"];
  109.     } else if ($this->role == 'ged') {
  110.       return ["ROLE_GED"];
  111.     }
  112.     return ['ROLE_USER'];
  113.   }
  114.   public function getSalt(): ?string
  115.   {
  116.     return null;
  117.   }
  118.   public function eraseCredentials(): void
  119.   {
  120.   }
  121.   public function equals(UserInterface $user): bool
  122.   {
  123.     return $user->getEmail() == $this->getEmail();
  124.   }
  125.   public function getUsername(): ?string
  126.   {
  127.     return $this->email;
  128.   }
  129.   /**
  130.    * The public representation of the user (e.g. a username, an email address, etc.)
  131.    *
  132.    * @see UserInterface
  133.    */
  134.   public function getUserIdentifier(): string
  135.   {
  136.     return (string) $this->email;
  137.   }
  138.   public function getId(): ?int
  139.   {
  140.     return $this->id;
  141.   }
  142.   public function getEmail(): ?string
  143.   {
  144.     return $this->email;
  145.   }
  146.   public function setEmail(?string $email): self
  147.   {
  148.     $this->email $email;
  149.     return $this;
  150.   }
  151.   public function getFontSize(): ?int
  152.   {
  153.     return $this->font_size;
  154.   }
  155.   public function setFontSize(?int $font_size): self
  156.   {
  157.     $this->font_size $font_size;
  158.     return $this;
  159.   }
  160.   public function getFontFamily(): ?string
  161.   {
  162.     return $this->font_family;
  163.   }
  164.   public function setFontFamily(?string $font_family): self
  165.   {
  166.     $this->font_family $font_family;
  167.     return $this;
  168.   }
  169.   public function getDarkMode(): ?int
  170.   {
  171.     return $this->dark_mode;
  172.   }
  173.   public function setDarkMode(?int $dark_mode): self
  174.   {
  175.     $this->dark_mode $dark_mode;
  176.     return $this;
  177.   }
  178.   public function getFirstName(): ?string
  179.   {
  180.     return $this->first_name;
  181.   }
  182.   public function setFirstName(?string $first_name): self
  183.   {
  184.     $this->first_name $first_name;
  185.     return $this;
  186.   }
  187.   public function getLastName(): ?string
  188.   {
  189.     return $this->last_name;
  190.   }
  191.   public function setLastName(?string $last_name): self
  192.   {
  193.     $this->last_name $last_name;
  194.     return $this;
  195.   }
  196.   public function getPhoneNumber(): ?string
  197.   {
  198.     return $this->phone_number;
  199.   }
  200.   public function setPhoneNumber(?string $phone_number): self
  201.   {
  202.     $this->phone_number $phone_number;
  203.     return $this;
  204.   }
  205.   public function getCreatedAt(): ?\DateTimeInterface
  206.   {
  207.     return $this->created_at;
  208.   }
  209.   public function setCreatedAt(?\DateTimeInterface $created_at): self
  210.   {
  211.     $this->created_at $created_at;
  212.     return $this;
  213.   }
  214.   public function getUpdatedAt(): ?\DateTimeInterface
  215.   {
  216.     return $this->updated_at;
  217.   }
  218.   public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  219.   {
  220.     $this->updated_at $updated_at;
  221.     return $this;
  222.   }
  223.   public function getTermVersion(): ?int
  224.   {
  225.     return $this->term_version;
  226.   }
  227.   public function setTermVersion(?int $term_version): self
  228.   {
  229.     $this->term_version $term_version;
  230.     return $this;
  231.   }
  232.   /**
  233.    * @return Collection|Post[]
  234.    */
  235.   public function getCreatedPosts(): Collection
  236.   {
  237.     return $this->created_posts;
  238.   }
  239.   public function addCreatedPost(Post $createdPost): self
  240.   {
  241.     if (!$this->created_posts->contains($createdPost)) {
  242.       $this->created_posts[] = $createdPost;
  243.       $createdPost->setCreatedBy($this);
  244.     }
  245.     return $this;
  246.   }
  247.   public function removeCreatedPost(Post $createdPost): self
  248.   {
  249.     if ($this->created_posts->contains($createdPost)) {
  250.       $this->created_posts->removeElement($createdPost);
  251.       // set the owning side to null (unless already changed)
  252.       if ($createdPost->getCreatedBy() === $this) {
  253.         $createdPost->setCreatedBy(null);
  254.       }
  255.     }
  256.     return $this;
  257.   }
  258.   /**
  259.    * @return Collection|Post[]
  260.    */
  261.   public function getUpdatedPosts(): Collection
  262.   {
  263.     return $this->updated_posts;
  264.   }
  265.   public function addUpdatedPost(Post $updatedPost): self
  266.   {
  267.     if (!$this->updated_posts->contains($updatedPost)) {
  268.       $this->updated_posts[] = $updatedPost;
  269.       $updatedPost->setUpdatedBy($this);
  270.     }
  271.     return $this;
  272.   }
  273.   public function removeUpdatedPost(Post $updatedPost): self
  274.   {
  275.     if ($this->updated_posts->contains($updatedPost)) {
  276.       $this->updated_posts->removeElement($updatedPost);
  277.       // set the owning side to null (unless already changed)
  278.       if ($updatedPost->getUpdatedBy() === $this) {
  279.         $updatedPost->setUpdatedBy(null);
  280.       }
  281.     }
  282.     return $this;
  283.   }
  284.   public function getRole(): ?string
  285.   {
  286.     return $this->role;
  287.   }
  288.   public function setRole(?string $role): self
  289.   {
  290.     $this->role $role;
  291.     return $this;
  292.   }
  293.   public function __toString(): string
  294.   {
  295.     return $this->first_name ' ' $this->last_name;
  296.   }
  297.   public function getPublic(): ?TargetPublic
  298.   {
  299.     return $this->public;
  300.   }
  301.   public function setPublic(?TargetPublic $public): self
  302.   {
  303.     $this->public $public;
  304.     return $this;
  305.   }
  306.   /**
  307.    * @return Collection|Post[]
  308.    */
  309.   public function getPosts(): Collection
  310.   {
  311.     return $this->posts;
  312.   }
  313.   public function addPost(Post $post): self
  314.   {
  315.     if (!$this->posts->contains($post)) {
  316.       $this->posts[] = $post;
  317.       $post->setEditUser($this);
  318.     }
  319.     return $this;
  320.   }
  321.   public function removePost(Post $post): self
  322.   {
  323.     if ($this->posts->contains($post)) {
  324.       $this->posts->removeElement($post);
  325.       // set the owning side to null (unless already changed)
  326.       if ($post->getEditUser() === $this) {
  327.         $post->setEditUser(null);
  328.       }
  329.     }
  330.     return $this;
  331.   }
  332.   /**
  333.    * @return Collection|PostLog[]
  334.    */
  335.   public function getPostLogs(): Collection
  336.   {
  337.     return $this->postLogs;
  338.   }
  339.   public function addPostLog(PostLog $postLog): self
  340.   {
  341.     if (!$this->postLogs->contains($postLog)) {
  342.       $this->postLogs[] = $postLog;
  343.       $postLog->setUser($this);
  344.     }
  345.     return $this;
  346.   }
  347.   public function removePostLog(PostLog $postLog): self
  348.   {
  349.     if ($this->postLogs->contains($postLog)) {
  350.       $this->postLogs->removeElement($postLog);
  351.       // set the owning side to null (unless already changed)
  352.       if ($postLog->getUser() === $this) {
  353.         $postLog->setUser(null);
  354.       }
  355.     }
  356.     return $this;
  357.   }
  358.   public function getTokenReset(): ?string
  359.   {
  360.     return $this->token_reset;
  361.   }
  362.   public function setTokenReset(?string $token_reset): self
  363.   {
  364.     $this->token_reset $token_reset;
  365.     return $this;
  366.   }
  367.   public function getActive(): ?bool
  368.   {
  369.     return $this->active;
  370.   }
  371.   public function setActive(bool $active): self
  372.   {
  373.     $this->active $active;
  374.     return $this;
  375.   }
  376.   public function getPrivatePostsOnly(): ?bool
  377.   {
  378.     return $this->private_posts_only;
  379.   }
  380.   public function setPrivatePostsOnly(bool $private_posts_only): self
  381.   {
  382.     $this->private_posts_only $private_posts_only;
  383.     return $this;
  384.   }
  385.   public function getTokenActivation(): ?string
  386.   {
  387.     return $this->token_activation;
  388.   }
  389.   public function setTokenActivation(?string $token_activation): self
  390.   {
  391.     $this->token_activation $token_activation;
  392.     return $this;
  393.   }
  394.   /**
  395.    * @return Collection|Post[]
  396.    */
  397.   public function getFavoris(): Collection
  398.   {
  399.     return $this->favoris;
  400.   }
  401.   public function addFavori(Post $favori): self
  402.   {
  403.     if (!$this->favoris->contains($favori)) {
  404.       $this->favoris[] = $favori;
  405.     }
  406.     return $this;
  407.   }
  408.   public function removeFavori(Post $favori): self
  409.   {
  410.     if ($this->favoris->contains($favori)) {
  411.       $this->favoris->removeElement($favori);
  412.     }
  413.     return $this;
  414.   }
  415.   /**
  416.    * @return Collection|Topic[]
  417.    */
  418.   public function getThematiques(): Collection
  419.   {
  420.     return $this->thematiques;
  421.   }
  422.   public function addThematique(Topic $thematique): self
  423.   {
  424.     if (!$this->thematiques->contains($thematique)) {
  425.       $this->thematiques[] = $thematique;
  426.     }
  427.     return $this;
  428.   }
  429.   public function removeThematique(Topic $thematique): self
  430.   {
  431.     if ($this->thematiques->contains($thematique)) {
  432.       $this->thematiques->removeElement($thematique);
  433.     }
  434.     return $this;
  435.   }
  436.   /**
  437.    * @return Collection|Territory[]
  438.    */
  439.   public function getTerritoires(): Collection
  440.   {
  441.     return $this->territoires;
  442.   }
  443.   public function addTerritoire(Territory $territoire): self
  444.   {
  445.     if (!$this->territoires->contains($territoire)) {
  446.       $this->territoires[] = $territoire;
  447.     }
  448.     return $this;
  449.   }
  450.   public function removeTerritoire(Territory $territoire): self
  451.   {
  452.     if ($this->territoires->contains($territoire)) {
  453.       $this->territoires->removeElement($territoire);
  454.     }
  455.     return $this;
  456.   }
  457.   /**
  458.    * @return Collection|PostLog[]
  459.    */
  460.   public function getTokens(): Collection
  461.   {
  462.     return $this->tokens;
  463.   }
  464.   public function addToken(AuthToken $postLog): self
  465.   {
  466.     if (!$this->tokens->contains($postLog)) {
  467.       $this->tokens[] = $postLog;
  468.       $postLog->setUser($this);
  469.     }
  470.     return $this;
  471.   }
  472.   public function removeToken(AuthToken $postLog): self
  473.   {
  474.     if ($this->tokens->contains($postLog)) {
  475.       $this->tokens->removeElement($postLog);
  476.       // set the owning side to null (unless already changed)
  477.       if ($postLog->getUser() === $this) {
  478.         $postLog->setUser(null);
  479.       }
  480.     }
  481.     return $this;
  482.   }
  483.   /**
  484.    * @return Collection|Incident[]
  485.    */
  486.   public function getIncidents(): Collection
  487.   {
  488.     return $this->incidents;
  489.   }
  490.   public function addIncident(Incident $incident): self
  491.   {
  492.     if (!$this->incidents->contains($incident)) {
  493.       $this->incidents[] = $incident;
  494.       $incident->setUser($this);
  495.     }
  496.     return $this;
  497.   }
  498.   public function removeIncident(Incident $incident): self
  499.   {
  500.     if ($this->incidents->removeElement($incident)) {
  501.       // set the owning side to null (unless already changed)
  502.       if ($incident->getUser() === $this) {
  503.         $incident->setUser(null);
  504.       }
  505.     }
  506.     return $this;
  507.   }
  508. }