src/Entity/MenuItems.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\MenuItemsRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. use ApiPlatform\Metadata\Get;
  13. use ApiPlatform\Metadata\Post;
  14. use ApiPlatform\Metadata\Put;
  15. use ApiPlatform\Metadata\Delete;
  16. use ApiPlatform\Metadata\GetCollection;
  17. #[ORM\Entity(repositoryClassMenuItemsRepository::class)]
  18. #[ApiResource(
  19.     normalizationContext: ['groups' => ['menu_items:read']],
  20.     denormalizationContext: ['groups' => ['menu_items:write']],
  21.     order: ['orders' => 'ASC'],
  22. )]
  23. #[GetCollection]
  24. #[Get]
  25. #[Put(security"is_granted('ROLE_ADMIN')")]
  26. #[Post(security"is_granted('ROLE_ADMIN')")]
  27. #[Delete(security"is_granted('ROLE_ADMIN')")]
  28. #[ApiFilter(SearchFilter::class, properties: ['menu.id' => 'exact','type' => 'exact''parent' => 'exact'])]
  29. class MenuItems
  30. {
  31.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  32.     #[ORM\Id]
  33.     #[ORM\GeneratedValue]
  34.     #[ORM\Column]
  35.     private ?int $id null;
  36.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $name null;
  39.     
  40.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  41.     #[ORM\Column(length100nullabletrue)]
  42.     private ?string $slug null;
  43.     #[ORM\Column(length1nullabletrue)]
  44.     private ?string $place null;
  45.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  46.     #[ORM\Column(length20nullabletrue)]
  47.     private ?string $type null;
  48.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  49.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  50.     private ?string $content null;
  51.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  52.     #[ORM\Column(nullabletrue)]
  53.     private ?int $orders null;
  54.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  55.     #[ORM\Column(length10nullabletrue)]
  56.     private ?string $active null;
  57.     #[ORM\Column(length10nullabletrue)]
  58.     private ?string $clickability null;
  59.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  60.     #[ORM\Column(length255nullabletrue)]
  61.     private ?string $menu_class null;
  62.     
  63.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  64.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'children')]
  65.     private ?self $parent null;
  66.     
  67.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  68.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class, cascade:['persist'])]
  69.     private Collection $children;
  70.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  71.     #[ORM\ManyToOne(inversedBy'menuItems')]
  72.     private ?Menu $menu null;
  73.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  74.     #[ORM\ManyToOne(inversedBy'menuItems')]
  75.     private ?MediaObject $media null;
  76.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  77.     #[ORM\Column(nullabletrue)]
  78.     private ?bool $disabled null;
  79.     #[Groups(['menu:read''menu_items:read''menu_items:write'])]
  80.     #[ORM\Column(length255nullabletrue)]
  81.     private ?string $imageUrl null;
  82.     public function __construct()
  83.     {
  84.         $this->children = new ArrayCollection();
  85.     }
  86.     public function getId(): ?int
  87.     {
  88.         return $this->id;
  89.     }
  90.     public function getName(): ?string
  91.     {
  92.         return $this->name;
  93.     }
  94.     public function setName(?string $name): self
  95.     {
  96.         $this->name $name;
  97.         return $this;
  98.     }
  99.     public function getSlug(): ?string
  100.     {
  101.         return $this->slug;
  102.     }
  103.     public function setSlug(?string $slug): self
  104.     {
  105.         $this->slug $slug;
  106.         return $this;
  107.     }
  108.     public function getPlace(): ?string
  109.     {
  110.         return $this->place;
  111.     }
  112.     public function setPlace(?string $place): self
  113.     {
  114.         $this->place $place;
  115.         return $this;
  116.     }
  117.     public function getType(): ?string
  118.     {
  119.         return $this->type;
  120.     }
  121.     public function setType(?string $type): self
  122.     {
  123.         $this->type $type;
  124.         return $this;
  125.     }
  126.     public function getContent(): ?string
  127.     {
  128.         return $this->content;
  129.     }
  130.     public function setContent(?string $content): self
  131.     {
  132.         $this->content $content;
  133.         return $this;
  134.     }
  135.     public function getOrders(): ?int
  136.     {
  137.         return $this->orders;
  138.     }
  139.     public function setOrders(?int $orders): self
  140.     {
  141.         $this->orders $orders;
  142.         return $this;
  143.     }
  144.     public function getActive(): ?string
  145.     {
  146.         return $this->active;
  147.     }
  148.     public function setActive(?string $active): self
  149.     {
  150.         $this->active $active;
  151.         return $this;
  152.     }
  153.     public function getClickability(): ?string
  154.     {
  155.         return $this->clickability;
  156.     }
  157.     public function setClickability(?string $clickability): self
  158.     {
  159.         $this->clickability $clickability;
  160.         return $this;
  161.     }
  162.     public function getMenuClass(): ?string
  163.     {
  164.         return $this->menu_class;
  165.     }
  166.     public function setMenuClass(?string $menu_class): self
  167.     {
  168.         $this->menu_class $menu_class;
  169.         return $this;
  170.     }
  171.     public function getParent(): ?self
  172.     {
  173.         return $this->parent;
  174.     }
  175.     public function setParent(?self $parent): self
  176.     {
  177.         $this->parent $parent;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, self>
  182.      */
  183.     public function getChildren(): Collection
  184.     {
  185.         return $this->children;
  186.     }
  187.     public function addChild(self $child): self
  188.     {
  189.         if (!$this->children->contains($child)) {
  190.             $this->children->add($child);
  191.             $child->setParent($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeChild(self $child): self
  196.     {
  197.         if ($this->children->removeElement($child)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($child->getParent() === $this) {
  200.                 $child->setParent(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.     public function getMenu(): ?Menu
  206.     {
  207.         return $this->menu;
  208.     }
  209.     public function setMenu(?Menu $menu): self
  210.     {
  211.         $this->menu $menu;
  212.         return $this;
  213.     }
  214.     public function getMedia(): ?MediaObject
  215.     {
  216.         return $this->media;
  217.     }
  218.     public function setMedia(?MediaObject $media): static
  219.     {
  220.         $this->media $media;
  221.         return $this;
  222.     }
  223.     public function isDisabled(): ?bool
  224.     {
  225.         return $this->disabled;
  226.     }
  227.     public function setDisabled(?bool $disabled): static
  228.     {
  229.         $this->disabled $disabled;
  230.         return $this;
  231.     }
  232.     public function getImageUrl(): ?string
  233.     {
  234.         return $this->imageUrl;
  235.     }
  236.     public function setImageUrl(?string $imageUrl): static
  237.     {
  238.         $this->imageUrl $imageUrl;
  239.         return $this;
  240.     }
  241. }