src/Entity/MenuType.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\MenuTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassMenuTypeRepository::class)]
  9. #[ApiResource]
  10. class MenuType
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $menuTypeName null;
  18.     #[ORM\OneToMany(mappedBy'menuType'targetEntityMenu::class, orphanRemovaltrue)]
  19.     private Collection $menus;
  20.     public function __construct()
  21.     {
  22.         $this->menus = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getMenuTypeName(): ?string
  29.     {
  30.         return $this->menuTypeName;
  31.     }
  32.     public function setMenuTypeName(string $menuTypeName): self
  33.     {
  34.         $this->menuTypeName $menuTypeName;
  35.         return $this;
  36.     }
  37.     /**
  38.      * @return Collection<int, Menu>
  39.      */
  40.     public function getMenus(): Collection
  41.     {
  42.         return $this->menus;
  43.     }
  44.     public function addMenu(Menu $menu): self
  45.     {
  46.         if (!$this->menus->contains($menu)) {
  47.             $this->menus->add($menu);
  48.             $menu->setMenuType($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeMenu(Menu $menu): self
  53.     {
  54.         if ($this->menus->removeElement($menu)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($menu->getMenuType() === $this) {
  57.                 $menu->setMenuType(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62. }