src/Entity/PageMenu.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\CommonTrait;
  4. use App\Repository\PageMenuRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass=PageMenuRepository::class)
  11.  * @ORM\Table(name="app_page_menu")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  * @UniqueEntity({"uuid"})
  14.  */
  15. class PageMenu
  16. {
  17.     use CommonTrait;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=PageMenuLink::class, mappedBy="menu", orphanRemoval=true)
  24.      */
  25.     private $links;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $uKey;
  30.     public function __construct()
  31.     {
  32.         $this->links = new ArrayCollection();
  33.     }
  34.     public function getName(): ?string
  35.     {
  36.         return $this->name;
  37.     }
  38.     public function setName(string $name): self
  39.     {
  40.         $this->name $name;
  41.         return $this;
  42.     }
  43.     /**
  44.      * @return Collection<int, PageMenuLink>
  45.      */
  46.     public function getLinks(): Collection
  47.     {
  48.         return $this->links;
  49.     }
  50.     public function addLink(PageMenuLink $link): self
  51.     {
  52.         if (!$this->links->contains($link)) {
  53.             $this->links[] = $link;
  54.             $link->setMenu($this);
  55.         }
  56.         return $this;
  57.     }
  58.     public function removeLink(PageMenuLink $link): self
  59.     {
  60.         if ($this->links->removeElement($link)) {
  61.             // set the owning side to null (unless already changed)
  62.             if ($link->getMenu() === $this) {
  63.                 $link->setMenu(null);
  64.             }
  65.         }
  66.         return $this;
  67.     }
  68.     public function getUKey(): ?string
  69.     {
  70.         return $this->uKey;
  71.     }
  72.     public function setUKey(string $uKey): self
  73.     {
  74.         $this->uKey $uKey;
  75.         return $this;
  76.     }
  77.     public function __toString(): string
  78.     {
  79.         return $this->name;
  80.     }
  81. }