src/Entity/User.php line 16

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\EquatableInterface;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  10.  * @ORM\Table(name="mmpp_user")
  11.  * @method string getUserIdentifier()
  12.  */
  13. class User implements UserInterface\Serializable
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\Column(type="integer")
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      */
  20.     protected $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=60, unique=true)
  23.      */
  24.     protected $username;
  25.     /**
  26.      * @ORM\Column(type="string", length=32)
  27.      */
  28.     protected $salt;
  29.     /**
  30.      * @ORM\Column(type="string", length=40)
  31.      */
  32.     protected $password;
  33.     /**
  34.      * @ORM\Column(type="string", length=60, unique=true)
  35.      */
  36.     protected $email;
  37.     /**
  38.      * @ORM\Column(name="is_active", type="boolean")
  39.      */
  40.     protected $isActive;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity="Tarif", mappedBy="user")
  43.      */
  44.     protected $tarifs;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity="Document", mappedBy="user")
  47.      */
  48.     protected $documents;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity="InscriptionFile", mappedBy="user")
  51.      */
  52.     protected $files;
  53.     public function __construct()
  54.     {
  55.         $this->tarifs = new ArrayCollection();
  56.         $this->documents = new ArrayCollection();
  57.         $this->files = new ArrayCollection();
  58.     }
  59.     /**
  60.      * @inheritDoc
  61.      */
  62.     public function getRoles()
  63.     {
  64.         return array('ROLE_USER');
  65.     }
  66.     /**
  67.      * @inheritDoc
  68.      */
  69.     public function eraseCredentials()
  70.     {
  71.     }
  72.     /**
  73.      * @inheritDoc
  74.      */
  75.     public function isEqualTo(UserInterface $user)
  76.     {
  77.         return $this->username === $user->getUsername();
  78.     }
  79.     public function isAccountNonExpired()
  80.     {
  81.         return true;
  82.     }
  83.     public function isAccountNonLocked()
  84.     {
  85.         return true;
  86.     }
  87.     public function isCredentialsNonExpired()
  88.     {
  89.         return true;
  90.     }
  91.     public function isEnabled()
  92.     {
  93.         return $this->isActive;
  94.     }
  95.     /**
  96.      * @see \Serializable::serialize()
  97.      */
  98.     public function serialize()
  99.     {
  100.         return serialize(array(
  101.             $this->id,
  102.         ));
  103.     }
  104.     /**
  105.      * @see \Serializable::unserialize()
  106.      */
  107.     public function unserialize($serialized)
  108.     {
  109.         list (
  110.             $this->id,
  111.         ) = unserialize($serialized);
  112.     }
  113.     public function __call(string $name, array $arguments)
  114.     {
  115.         // TODO: Implement @method string getUserIdentifier()
  116.     }
  117.     public function getId(): ?int
  118.     {
  119.         return $this->id;
  120.     }
  121.     public function getUsername()
  122.     {
  123.         return $this->username;
  124.     }
  125.     public function setUsername($username)
  126.     {
  127.         $this->username $username;
  128.         return $this;
  129.     }
  130.     public function getSalt()
  131.     {
  132.         return $this->salt;
  133.     }
  134.     public function setSalt($salt)
  135.     {
  136.         $this->salt $salt;
  137.         return $this;
  138.     }
  139.     public function getPassword()
  140.     {
  141.         return $this->password;
  142.     }
  143.     public function setPassword($password)
  144.     {
  145.         $this->password $password;
  146.         return $this;
  147.     }
  148.     public function getEmail(): ?string
  149.     {
  150.         return $this->email;
  151.     }
  152.     public function setEmail(string $email): self
  153.     {
  154.         $this->email $email;
  155.         return $this;
  156.     }
  157.     public function setIsActive(bool $isActive): self
  158.     {
  159.         $this->isActive $isActive;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, Tarif>
  164.      */
  165.     public function getTarifs(): Collection
  166.     {
  167.         return $this->tarifs;
  168.     }
  169.     public function addTarif(Tarif $tarif): self
  170.     {
  171.         if (!$this->tarifs->contains($tarif)) {
  172.             $this->tarifs->add($tarif);
  173.             $tarif->setUser($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeTarif(Tarif $tarif): self
  178.     {
  179.         if ($this->tarifs->removeElement($tarif)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($tarif->getUser() === $this) {
  182.                 $tarif->setUser(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, Document>
  189.      */
  190.     public function getDocuments(): Collection
  191.     {
  192.         return $this->documents;
  193.     }
  194.     public function addDocument(Document $document): self
  195.     {
  196.         if (!$this->documents->contains($document)) {
  197.             $this->documents->add($document);
  198.             $document->setUser($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeDocument(Document $document): self
  203.     {
  204.         if ($this->documents->removeElement($document)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($document->getUser() === $this) {
  207.                 $document->setUser(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, InscriptionFile>
  214.      */
  215.     public function getFiles(): Collection
  216.     {
  217.         return $this->files;
  218.     }
  219.     public function addFile(InscriptionFile $file): self
  220.     {
  221.         if (!$this->files->contains($file)) {
  222.             $this->files->add($file);
  223.             $file->setUser($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeFile(InscriptionFile $file): self
  228.     {
  229.         if ($this->files->removeElement($file)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($file->getUser() === $this) {
  232.                 $file->setUser(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     public function isIsActive(): ?bool
  238.     {
  239.         return $this->isActive;
  240.     }
  241. }