src/Entity/Menu.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\MainTranslationTrait;
  4. use App\Entity\Translation\MenuTranslation;
  5. use App\Repository\MenuRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Gedmo\Translatable\Translatable;
  11. #[ORM\Table(name'menu')]
  12. #[ORM\Entity(repositoryClassMenuRepository::class)]
  13. #[Gedmo\TranslationEntity(class: MenuTranslation::class)]
  14. class Menu implements Translatable
  15. {
  16.     use MainTranslationTrait;
  17.     const TRANSLATION_ENTITY MenuTranslation::class;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     public function __toString(): string
  23.     {
  24.         return $this->title ?? "";
  25.     }
  26.     #[ORM\Column(type'string'nullabletrue)]
  27.     #[Gedmo\Translatable]
  28.     private ?string $title null;
  29.     #[ORM\Column(type'string',uniquetruenullabletrue)]
  30.     private ?string $url null;
  31.     #[ORM\Column(type'integer'nullabletrue)]
  32.     private ?int $position null;
  33.     #[ORM\OneToMany(mappedBy'menu'targetEntityChildMenu::class, cascade: ['persist''remove'])]
  34.     private Collection $childMenu;
  35.     #[ORM\Column(type'boolean'nullabletrue)]
  36.     private ?bool $showInFooter null;
  37.     #[ORM\Column(type'boolean'nullabletrue)]
  38.     private ?bool $showInHeader null;
  39.     public function __construct()
  40.     {
  41.         $this->childMenu = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     /**
  48.      * @return mixed
  49.      */
  50.     public function getChildMenu()
  51.     {
  52.         return $this->childMenu;
  53.     }
  54.     /**
  55.      * @param  mixed  $childMenu
  56.      */
  57.     public function setChildMenu($childMenu): void
  58.     {
  59.         $this->childMenu $childMenu;
  60.     }
  61.     public function addChildMenu(ChildMenu $childMenu): static
  62.     {
  63.         if (!$this->childMenu->contains($childMenu)) {
  64.             $this->childMenu->add($childMenu);
  65.             $childMenu->setMenu($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeChildMenu(ChildMenu $childMenu): static
  70.     {
  71.         if ($this->childMenu->removeElement($childMenu)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($childMenu->getMenu() === $this) {
  74.                 $childMenu->setMenu(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79.     public function getTitle(): ?string
  80.     {
  81.         return $this->title;
  82.     }
  83.     public function setTitle(?string $title): void
  84.     {
  85.         $this->title $title;
  86.     }
  87.     public function getPosition(): ?int
  88.     {
  89.         return $this->position;
  90.     }
  91.     public function setPosition(?int $position): void
  92.     {
  93.         $this->position $position;
  94.     }
  95.     public function getUrl(): ?string
  96.     {
  97.         return $this->url;
  98.     }
  99.     public function setUrl(?string $url): void
  100.     {
  101.         $this->url $url;
  102.     }
  103.     public function getShowInFooter(): ?bool
  104.     {
  105.         return $this->showInFooter;
  106.     }
  107.     public function setShowInFooter(?bool $showInFooter): void
  108.     {
  109.         $this->showInFooter $showInFooter;
  110.     }
  111.     public function getShowInHeader(): ?bool
  112.     {
  113.         return $this->showInHeader;
  114.     }
  115.     public function setShowInHeader(?bool $showInHeader): void
  116.     {
  117.         $this->showInHeader $showInHeader;
  118.     }
  119. }