Advertisement
Guest User

user

a guest
Feb 17th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.57 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10.  
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  13.  */
  14. class User implements UserInterface, \Serializable
  15. {
  16.    
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.  
  24.     /**
  25.      * @ORM\Column(type="string", length=180, unique=true)
  26.      */
  27.     private $username;
  28.  
  29.     /**
  30.      * @Gedmo\Slug(fields={"username"})
  31.      * @ORM\Column(length=255, unique=true)
  32.      */
  33.     private $slug;
  34.  
  35.     /**
  36.      * @ORM\Column(type="array")
  37.      */
  38.     private $roles = [];
  39.  
  40.     /**
  41.      * @ORM\Column(type="string", length=64)
  42.      */
  43.     private $password;
  44.     private $plainPassword;
  45.     private $plainPasswordConfirm;
  46.  
  47.  
  48.     /**
  49.      * @ORM\OneToMany(targetEntity="App\Entity\Classification", mappedBy="user", orphanRemoval=true)
  50.      */
  51.     private $classification;
  52.    
  53.     /**
  54.      * @var \DateTime $createdAt
  55.      *
  56.      * @Gedmo\Timestampable(on="create")
  57.      * @ORM\Column(type="datetime")
  58.      */
  59.     private $createdAt;
  60.  
  61.     /**
  62.      * @var \DateTime $updatedAt
  63.      *
  64.      * @Gedmo\Timestampable(on="update")
  65.      * @ORM\Column(type="datetime")
  66.      */
  67.     private $updatedAt;
  68.  
  69.     /**
  70.      * @ORM\OneToMany(targetEntity="App\Entity\Comments", mappedBy="user")
  71.      */
  72.     private $comments;
  73.  
  74.     /**
  75.      * @ORM\OneToMany(targetEntity="App\Entity\Inbox", mappedBy="user", orphanRemoval=true)
  76.      */
  77.     private $inboxes;
  78.  
  79.     /**
  80.      * @ORM\OneToMany(targetEntity="App\Entity\Inbox", mappedBy="sender")
  81.      */
  82.     private $inboxSenders;
  83.  
  84.     /**
  85.      * @ORM\OneToMany(targetEntity="App\Entity\Inbox", mappedBy="receiver")
  86.      */
  87.     private $inboxReceivers;
  88.  
  89.  
  90.     public function __construct()
  91.     {
  92.         $this->classification = new ArrayCollection();
  93.         $this->createdAt = new \Datetime();
  94.         $this->updatedAt = new \Datetime();
  95.         $this->comments = new ArrayCollection();
  96.         $this->inboxes = new ArrayCollection();
  97.         $this->inboxSenders = new ArrayCollection();
  98.         $this->inboxReceivers = new ArrayCollection();
  99.     }
  100.  
  101.  
  102.    
  103.     public function getId(): ?int
  104.     {
  105.         return $this->id;
  106.     }
  107.  
  108.     /**
  109.      * A visual identifier that represents this user.
  110.      *
  111.      * @see UserInterface
  112.      */
  113.     public function getUsername(): string
  114.     {
  115.         return (string) $this->username;
  116.     }
  117.  
  118.     public function setUsername(string $username): self
  119.     {
  120.         $this->username = $username;
  121.  
  122.         return $this;
  123.     }
  124.  
  125.     public function getSlug(): ?string
  126.     {
  127.         return $this->slug;
  128.     }
  129.  
  130.     public function setSlug(string $slug): self
  131.     {
  132.         $this->slug = $slug;
  133.  
  134.         return $this;    
  135.     }
  136.    
  137.  
  138.     public function setRoles(array $roles): self
  139.     {
  140.         $this->roles = $roles;
  141.  
  142.         return $this;
  143.     }
  144.  
  145.     public function getRoles(): array  
  146.     {
  147.         $roles = $this->roles;    
  148.         // $roles[] = 'ROLE_MEMBER';
  149.         return array_unique($roles);
  150.     }
  151.  
  152.     public function getPassword(): ?string
  153.     {
  154.         return $this->password;
  155.     }
  156.    
  157.     public function setPassword($password): self
  158.     {
  159.         $this->password = $password;
  160.        
  161.         return $this;
  162.     }
  163.    
  164.     public function getPlainPassword(): ?string
  165.     {
  166.         return $this->plainPassword;
  167.     }
  168.  
  169.     public function setPlainPassword($plainPassword): self
  170.     {
  171.         $this->plainPassword = $plainPassword;
  172.        
  173.         return $this;
  174.     }
  175.  
  176.     public function getPlainPasswordConfirm(): ?string
  177.     {
  178.         return $this->plainPasswordConfirm;
  179.     }
  180.  
  181.     public function setPlainPasswordConfirm($plainPasswordConfirm): self
  182.     {
  183.         $this->plainPasswordConfirm = $plainPasswordConfirm;
  184.        
  185.         return $this;
  186.     }
  187.  
  188.    
  189.     /**
  190.      * @see UserInterface
  191.      */
  192.     public function getSalt()
  193.     {
  194.         // not needed when using the "bcrypt" algorithm in security.yaml
  195.     }
  196.  
  197.     /**
  198.      * @see UserInterface
  199.      */
  200.     public function eraseCredentials()
  201.     {
  202.         // If you store any temporary, sensitive data on the user, clear it here
  203.         // $this->plainPassword = null;
  204.     }
  205.  
  206.     /** @see \Serializable::serialize() */
  207.  
  208.     public function serialize()
  209.     {
  210.         return serialize(array(
  211.             $this->id,
  212.             $this->username,
  213.             $this->password,
  214.  
  215.         ));
  216.     }
  217.  
  218.     public function unserialize($serialized)
  219.     {
  220.         list(
  221.             $this->id,
  222.             $this->username,
  223.             $this->password,
  224.         ) = unserialize($serialized);
  225.     }
  226.  
  227.     public function __toString()
  228.     {
  229.         return (string) $this->username;
  230.     }
  231.  
  232.     /**
  233.      * @return Collection|Classification[]
  234.      */
  235.     public function getClassification(): Collection
  236.     {
  237.         return $this->classification;
  238.     }
  239.  
  240.     public function addClassification(Classification $classification): self
  241.     {
  242.         if (!$this->classification->contains($classification)) {
  243.             $this->classification[] = $classification;
  244.             $classification->setUser($this);
  245.         }
  246.  
  247.         return $this;
  248.     }
  249.  
  250.     public function removeClassification(Classification $classification): self
  251.     {
  252.         if ($this->classification->contains($classification)) {
  253.             $this->classification->removeElement($classification);
  254.             // set the owning side to null (unless already changed)
  255.             if ($classification->getUser() === $this) {
  256.                 $classification->setUser(null);
  257.             }
  258.         }
  259.  
  260.         return $this;
  261.     }
  262.  
  263.  
  264.     public function getCreatedAt(): ?\DateTimeInterface
  265.     {
  266.         return $this->createdAt;
  267.     }
  268.  
  269.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  270.     {
  271.         $this->createdAt = $createdAt;
  272.  
  273.         return $this;
  274.     }
  275.  
  276.     public function getUpdatedAt(): ?\DateTimeInterface
  277.     {
  278.         return $this->updatedAt;
  279.     }
  280.  
  281.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  282.     {
  283.         $this->updatedAt = $updatedAt;
  284.  
  285.         return $this;
  286.     }
  287.  
  288.     /**
  289.      * @return Collection|Comments[]
  290.      */
  291.     public function getComments(): Collection
  292.     {
  293.         return $this->comments;
  294.     }
  295.  
  296.     public function addComment(Comments $comment): self
  297.     {
  298.         if (!$this->comments->contains($comment)) {
  299.             $this->comments[] = $comment;
  300.             $comment->setUser($this);
  301.         }
  302.  
  303.         return $this;
  304.     }
  305.  
  306.     public function removeComment(Comments $comment): self
  307.     {
  308.         if ($this->comments->contains($comment)) {
  309.             $this->comments->removeElement($comment);
  310.             // set the owning side to null (unless already changed)
  311.             if ($comment->getUser() === $this) {
  312.                 $comment->setUser(null);
  313.             }
  314.         }
  315.  
  316.         return $this;
  317.     }
  318.  
  319.     /**
  320.      * @return Collection|Inbox[]
  321.      */
  322.     public function getInboxes(): Collection
  323.     {
  324.         return $this->inboxes;
  325.     }
  326.  
  327.     public function addInbox(Inbox $inbox): self
  328.     {
  329.         if (!$this->inboxes->contains($inbox)) {
  330.             $this->inboxes[] = $inbox;
  331.             $inbox->setUser($this);
  332.         }
  333.  
  334.         return $this;
  335.     }
  336.  
  337.     public function removeInbox(Inbox $inbox): self
  338.     {
  339.         if ($this->inboxes->contains($inbox)) {
  340.             $this->inboxes->removeElement($inbox);
  341.             // set the owning side to null (unless already changed)
  342.             if ($inbox->getUser() === $this) {
  343.                 $inbox->setUser(null);
  344.             }
  345.         }
  346.  
  347.         return $this;
  348.     }
  349.  
  350.     /**
  351.      * @return Collection|Inbox[]
  352.      */
  353.     public function getInboxSenders(): Collection
  354.     {
  355.         return $this->inboxSenders;
  356.     }
  357.  
  358.     public function addInboxSender(Inbox $inboxSender): self
  359.     {
  360.         if (!$this->inboxSenders->contains($inboxSender)) {
  361.             $this->inboxSenders[] = $inboxSender;
  362.             $inboxSender->setSender($this);
  363.         }
  364.  
  365.         return $this;
  366.     }
  367.  
  368.     public function removeInboxSender(Inbox $inboxSender): self
  369.     {
  370.         if ($this->inboxSenders->contains($inboxSender)) {
  371.             $this->inboxSenders->removeElement($inboxSender);
  372.             // set the owning side to null (unless already changed)
  373.             if ($inboxSender->getSender() === $this) {
  374.                 $inboxSender->setSender(null);
  375.             }
  376.         }
  377.  
  378.         return $this;
  379.     }
  380.  
  381.     /**
  382.      * @return Collection|Inbox[]
  383.      */
  384.     public function getInboxReceivers(): Collection
  385.     {
  386.         return $this->inboxReceivers;
  387.     }
  388.  
  389.     public function addInboxReceiver(Inbox $inboxReceiver): self
  390.     {
  391.         if (!$this->inboxReceivers->contains($inboxReceiver)) {
  392.             $this->inboxReceivers[] = $inboxReceiver;
  393.             $inboxReceiver->setReceiver($this);
  394.         }
  395.  
  396.         return $this;
  397.     }
  398.  
  399.     public function removeInboxReceiver(Inbox $inboxReceiver): self
  400.     {
  401.         if ($this->inboxReceivers->contains($inboxReceiver)) {
  402.             $this->inboxReceivers->removeElement($inboxReceiver);
  403.             // set the owning side to null (unless already changed)
  404.             if ($inboxReceiver->getReceiver() === $this) {
  405.                 $inboxReceiver->setReceiver(null);
  406.             }
  407.         }
  408.  
  409.         return $this;
  410.     }
  411.  
  412.    
  413.  
  414.  
  415.  
  416.  
  417. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement