<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use FOS\UserBundle\Model\User as AbstractUser;use Kunstmaan\AdminBundle\Entity\EntityInterface;/** * @ORM\Entity(repositoryClass="App\Repository\LifesaverRepository") */class Lifesaver extends AbstractUser implements EntityInterface{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ protected $id; /** * @ORM\ManyToMany(targetEntity="App\Entity\Beach", inversedBy="lifesavers") */ protected $beaches; /** * @ORM\OneToMany(targetEntity=LifesaverLoginToken::class, mappedBy="lifesaver", orphanRemoval=true) */ private $lifesaverLoginTokens; public function __construct() { $this->beaches = new ArrayCollection(); $this->enabled = true; $this->lifesaverLoginTokens = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setId($id) { $this->id = $id; return $this; } /** * @return Collection|Beach[] */ public function getBeaches(): Collection { return $this->beaches; } public function addBeach(Beach $beach): self { if (!$this->beaches->contains($beach)) { $this->beaches[] = $beach; } return $this; } public function removeBeach(Beach $beach): self { if ($this->beaches->contains($beach)) { $this->beaches->removeElement($beach); } return $this; } public function __toString() { return $this->getUsername(); } /** * @return Collection|LifesaverLoginToken[] */ public function getLifesaverLoginTokens(): Collection { return $this->lifesaverLoginTokens; } public function addLifesaverLoginToken(LifesaverLoginToken $lifesaverLoginToken): self { if (!$this->lifesaverLoginTokens->contains($lifesaverLoginToken)) { $this->lifesaverLoginTokens[] = $lifesaverLoginToken; $lifesaverLoginToken->setLifesaver($this); } return $this; } public function removeLifesaverLoginToken(LifesaverLoginToken $lifesaverLoginToken): self { if ($this->lifesaverLoginTokens->contains($lifesaverLoginToken)) { $this->lifesaverLoginTokens->removeElement($lifesaverLoginToken); // set the owning side to null (unless already changed) if ($lifesaverLoginToken->getLifesaver() === $this) { $lifesaverLoginToken->setLifesaver(null); } } return $this; }}