src/Entity/Website/Menu/Menu.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Website\Menu;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Website\Website\Website;
  5. use App\Repository\Website\Menu\MenuRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  10. #[ORM\Entity(repositoryClassMenuRepository::class)]
  11. class Menu extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'guid'uniquetrue)]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     private ?string $id;
  18.     #[ORM\ManyToOne(inversedBy'menus')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?Website $website null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $position null;
  23.     #[ORM\OneToMany(mappedBy'menu'targetEntityMenuItem::class)]
  24.     private Collection $menuItems;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $title null;
  27.     public function __toString()
  28.     {
  29.         return $this->getId();
  30.     }
  31.     public function __construct()
  32.     {
  33.         parent::__construct();
  34.         $this->menuItems = new ArrayCollection();
  35.     }
  36.     public function getId(): ?string
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getWebsite(): ?Website
  41.     {
  42.         return $this->website;
  43.     }
  44.     public function setWebsite(?Website $shop): static
  45.     {
  46.         $this->website $shop;
  47.         return $this;
  48.     }
  49.     public function getPosition(): ?string
  50.     {
  51.         return $this->position;
  52.     }
  53.     public function setPosition(string $position): static
  54.     {
  55.         $this->position $position;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return Collection<int, MenuItem>
  60.      */
  61.     public function getMenuItems(): Collection
  62.     {
  63.         return $this->menuItems;
  64.     }
  65.     public function addMenuItem(MenuItem $menuItem): static
  66.     {
  67.         if (!$this->menuItems->contains($menuItem)) {
  68.             $this->menuItems->add($menuItem);
  69.             $menuItem->setMenu($this);
  70.         }
  71.         return $this;
  72.     }
  73.     public function removeMenuItem(MenuItem $menuItem): static
  74.     {
  75.         if ($this->menuItems->removeElement($menuItem)) {
  76.             // set the owning side to null (unless already changed)
  77.             if ($menuItem->getMenu() === $this) {
  78.                 $menuItem->setMenu(null);
  79.             }
  80.         }
  81.         return $this;
  82.     }
  83.     public function getTitle(): ?string
  84.     {
  85.         return $this->title;
  86.     }
  87.     public function setTitle(?string $title): static
  88.     {
  89.         $this->title $title;
  90.         return $this;
  91.     }
  92. }