src/Entity/MenuItems.php line 32
- <?php
- namespace App\Entity;
- use ApiPlatform\Metadata\ApiResource;
- use App\Repository\MenuItemsRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\DBAL\Types\Types;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Serializer\Annotation\Groups;
- use ApiPlatform\Metadata\ApiFilter;
- use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\Post;
- use ApiPlatform\Metadata\Put;
- use ApiPlatform\Metadata\Delete;
- use ApiPlatform\Metadata\GetCollection;
- #[ORM\Entity(repositoryClass: MenuItemsRepository::class)]
- #[ApiResource(
- normalizationContext: ['groups' => ['menu_items:read']],
- denormalizationContext: ['groups' => ['menu_items:write']],
- order: ['orders' => 'ASC'],
- )]
- #[GetCollection]
- #[Get]
- #[Put(security: "is_granted('ROLE_ADMIN')")]
- #[Post(security: "is_granted('ROLE_ADMIN')")]
- #[Delete(security: "is_granted('ROLE_ADMIN')")]
- #[ApiFilter(SearchFilter::class, properties: ['menu.id' => 'exact','type' => 'exact', 'parent' => 'exact'])]
- class MenuItems
- {
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Id]
- #[ORM\GeneratedValue]
- #[ORM\Column]
- private ?int $id = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $name = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(length: 100, nullable: true)]
- private ?string $slug = null;
- #[ORM\Column(length: 1, nullable: true)]
- private ?string $place = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(length: 20, nullable: true)]
- private ?string $type = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(type: Types::TEXT, nullable: true)]
- private ?string $content = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(nullable: true)]
- private ?int $orders = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(length: 10, nullable: true)]
- private ?string $active = null;
- #[ORM\Column(length: 10, nullable: true)]
- private ?string $clickability = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $menu_class = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
- private ?self $parent = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, cascade:['persist'])]
- private Collection $children;
- #[ORM\ManyToOne]
- private ?Pages $page = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\ManyToOne(inversedBy: 'menuItems')]
- private ?Menu $menu = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\ManyToOne(inversedBy: 'menuItems')]
- private ?MediaObject $media = null;
- #[Groups(['menu:read', 'menu_items:read', 'menu_items:write'])]
- #[ORM\Column(nullable: true)]
- private ?bool $disabled = null;
- public function __construct()
- {
- $this->children = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(?string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getSlug(): ?string
- {
- return $this->slug;
- }
- public function setSlug(?string $slug): self
- {
- $this->slug = $slug;
- return $this;
- }
- public function getPlace(): ?string
- {
- return $this->place;
- }
- public function setPlace(?string $place): self
- {
- $this->place = $place;
- return $this;
- }
- public function getType(): ?string
- {
- return $this->type;
- }
- public function setType(?string $type): self
- {
- $this->type = $type;
- return $this;
- }
- public function getContent(): ?string
- {
- return $this->content;
- }
- public function setContent(?string $content): self
- {
- $this->content = $content;
- return $this;
- }
- public function getOrders(): ?int
- {
- return $this->orders;
- }
- public function setOrders(?int $orders): self
- {
- $this->orders = $orders;
- return $this;
- }
- public function getActive(): ?string
- {
- return $this->active;
- }
- public function setActive(?string $active): self
- {
- $this->active = $active;
- return $this;
- }
- public function getClickability(): ?string
- {
- return $this->clickability;
- }
- public function setClickability(?string $clickability): self
- {
- $this->clickability = $clickability;
- return $this;
- }
- public function getMenuClass(): ?string
- {
- return $this->menu_class;
- }
- public function setMenuClass(?string $menu_class): self
- {
- $this->menu_class = $menu_class;
- return $this;
- }
- public function getParent(): ?self
- {
- return $this->parent;
- }
- public function setParent(?self $parent): self
- {
- $this->parent = $parent;
- return $this;
- }
- /**
- * @return Collection<int, self>
- */
- public function getChildren(): Collection
- {
- return $this->children;
- }
- public function addChild(self $child): self
- {
- if (!$this->children->contains($child)) {
- $this->children->add($child);
- $child->setParent($this);
- }
- return $this;
- }
- public function removeChild(self $child): self
- {
- if ($this->children->removeElement($child)) {
- // set the owning side to null (unless already changed)
- if ($child->getParent() === $this) {
- $child->setParent(null);
- }
- }
- return $this;
- }
- public function getPage(): ?Pages
- {
- return $this->page;
- }
- public function setPage(?Pages $page): self
- {
- $this->page = $page;
- return $this;
- }
- public function getMenu(): ?Menu
- {
- return $this->menu;
- }
- public function setMenu(?Menu $menu): self
- {
- $this->menu = $menu;
- return $this;
- }
- public function getMedia(): ?MediaObject
- {
- return $this->media;
- }
- public function setMedia(?MediaObject $media): static
- {
- $this->media = $media;
- return $this;
- }
- public function isDisabled(): ?bool
- {
- return $this->disabled;
- }
- public function setDisabled(?bool $disabled): static
- {
- $this->disabled = $disabled;
- return $this;
- }
- }