src/Entity/Lifesaver.php line 14

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 FOS\UserBundle\Model\User as AbstractUser;
  7. use Kunstmaan\AdminBundle\Entity\EntityInterface;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\LifesaverRepository")
  10.  */
  11. class Lifesaver extends AbstractUser implements EntityInterface
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     protected $id;
  19.     /**
  20.      * @ORM\ManyToMany(targetEntity="App\Entity\Beach", inversedBy="lifesavers")
  21.      */
  22.     protected $beaches;
  23.     /**
  24.      * @ORM\OneToMany(targetEntity=LifesaverLoginToken::class, mappedBy="lifesaver", orphanRemoval=true)
  25.      */
  26.     private $lifesaverLoginTokens;
  27.     public function __construct()
  28.     {
  29.         $this->beaches = new ArrayCollection();
  30.         $this->enabled true;
  31.         $this->lifesaverLoginTokens = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function setId($id)
  38.     {
  39.         $this->id $id;
  40.         return $this;
  41.     }
  42.     /**
  43.      * @return Collection|Beach[]
  44.      */
  45.     public function getBeaches(): Collection
  46.     {
  47.         return $this->beaches;
  48.     }
  49.     public function addBeach(Beach $beach): self
  50.     {
  51.         if (!$this->beaches->contains($beach)) {
  52.             $this->beaches[] = $beach;
  53.         }
  54.         return $this;
  55.     }
  56.     public function removeBeach(Beach $beach): self
  57.     {
  58.         if ($this->beaches->contains($beach)) {
  59.             $this->beaches->removeElement($beach);
  60.         }
  61.         return $this;
  62.     }
  63.     public function __toString()
  64.     {
  65.         return $this->getUsername();
  66.     }
  67.     /**
  68.      * @return Collection|LifesaverLoginToken[]
  69.      */
  70.     public function getLifesaverLoginTokens(): Collection
  71.     {
  72.         return $this->lifesaverLoginTokens;
  73.     }
  74.     public function addLifesaverLoginToken(LifesaverLoginToken $lifesaverLoginToken): self
  75.     {
  76.         if (!$this->lifesaverLoginTokens->contains($lifesaverLoginToken)) {
  77.             $this->lifesaverLoginTokens[] = $lifesaverLoginToken;
  78.             $lifesaverLoginToken->setLifesaver($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeLifesaverLoginToken(LifesaverLoginToken $lifesaverLoginToken): self
  83.     {
  84.         if ($this->lifesaverLoginTokens->contains($lifesaverLoginToken)) {
  85.             $this->lifesaverLoginTokens->removeElement($lifesaverLoginToken);
  86.             // set the owning side to null (unless already changed)
  87.             if ($lifesaverLoginToken->getLifesaver() === $this) {
  88.                 $lifesaverLoginToken->setLifesaver(null);
  89.             }
  90.         }
  91.         return $this;
  92.     }
  93. }