src/Entity/Pages.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\PagesRepository;
  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 ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Metadata\GetCollection;
  12. use ApiPlatform\Metadata\ApiProperty;
  13. use ApiPlatform\Metadata\Post;
  14. use ApiPlatform\Metadata\Get;
  15. use ApiPlatform\Metadata\Delete;
  16. use ApiPlatform\Metadata\Put;
  17. use Symfony\Component\HttpFoundation\File\File;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  20. #[ORM\Entity(repositoryClassPagesRepository::class)]
  21. #[Get]
  22. #[Put(security"is_granted('ROLE_ADMIN')")]
  23. #[Post(security"is_granted('ROLE_ADMIN')")]
  24. #[Delete(security"is_granted('ROLE_ADMIN')")]
  25. #[ApiResource(
  26.     normalizationContext: ['groups' => ['read']],
  27.     denormalizationContext: ['groups' => ['write']],
  28.     order: ['id' => 'DESC']
  29. )]
  30. #[ApiFilter(SearchFilter::class, properties: ['synonym' => 'exact''categories.id' => 'exact''name' => 'ipartial', ])]
  31. class Pages
  32. {
  33.     #[ORM\Id]
  34.     #[ORM\GeneratedValue]
  35.     #[ORM\Column]
  36.     #[Groups(['read''write'])]
  37.     private ?int $id null;
  38.     
  39.     #[Groups(['read''write'])]
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $name null;
  42.     #[Groups(['read''write'])]
  43.     #[ORM\ManyToOne(targetEntityself::class)]
  44.     private ?self $parent null;
  45.     #[Groups(['read''write'])]
  46.     #[ORM\Column(length100nullabletrue)]
  47.     private ?string $synonym null;
  48.     #[ORM\Column(length1nullabletrue)]
  49.     private ?string $place null;
  50.     #[ORM\Column(length20nullabletrue)]
  51.     private ?string $type null;
  52.     #[Groups(['read''write'])]
  53.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  54.     private ?string $content null;
  55.     #[Groups(['read''write'])]
  56.     #[ORM\Column(nullabletrue)]
  57.     private ?int $orders null;
  58.     #[ORM\Column(length10nullabletrue)]
  59.     private ?string $active null;
  60.     #[ORM\Column(length10nullabletrue)]
  61.     private ?string $clickability null;
  62.     #[ORM\Column(length10nullabletrue)]
  63.     private ?string $menu_class null;
  64.     #[Groups(['read''write'])]
  65.     #[ORM\Column(length255nullabletrue)]
  66.     private ?string $images null;
  67.     #[Groups(['read''write'])]
  68.     #[ORM\ManyToMany(targetEntityCategory::class, inversedBy'pages')]
  69.     private Collection $categories;
  70.     public function __construct()
  71.     {
  72.         $this->categories = new ArrayCollection();
  73.     }
  74.     
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getName(): ?string
  80.     {
  81.         return $this->name;
  82.     }
  83.     public function setName(?string $name): self
  84.     {
  85.         $this->name $name;
  86.         return $this;
  87.     }
  88.     public function getParent(): ?self
  89.     {
  90.         return $this->parent;
  91.     }
  92.     public function setParent(?self $parent): self
  93.     {
  94.         $this->parent $parent;
  95.         return $this;
  96.     }
  97.     public function getSynonym(): ?string
  98.     {
  99.         return $this->synonym;
  100.     }
  101.     public function setSynonym(?string $synonym): self
  102.     {
  103.         $this->synonym $synonym;
  104.         return $this;
  105.     }
  106.     public function getPlace(): ?string
  107.     {
  108.         return $this->place;
  109.     }
  110.     public function setPlace(?string $place): self
  111.     {
  112.         $this->place $place;
  113.         return $this;
  114.     }
  115.     public function getType(): ?string
  116.     {
  117.         return $this->type;
  118.     }
  119.     public function setType(?string $type): self
  120.     {
  121.         $this->type $type;
  122.         return $this;
  123.     }
  124.     public function getContent(): ?string
  125.     {
  126.         return $this->content;
  127.     }
  128.     public function setContent(?string $content): self
  129.     {
  130.         $this->content $content;
  131.         return $this;
  132.     }
  133.     public function getOrders(): ?int
  134.     {
  135.         return $this->orders;
  136.     }
  137.     public function setOrders(int $orders): self
  138.     {
  139.         $this->orders $orders;
  140.         return $this;
  141.     }
  142.     public function getActive(): ?string
  143.     {
  144.         return $this->active;
  145.     }
  146.     public function setActive(?string $active): self
  147.     {
  148.         $this->active $active;
  149.         return $this;
  150.     }
  151.     public function getClickability(): ?string
  152.     {
  153.         return $this->clickability;
  154.     }
  155.     public function setClickability(?string $clickability): self
  156.     {
  157.         $this->clickability $clickability;
  158.         return $this;
  159.     }
  160.     public function getMenuClass(): ?string
  161.     {
  162.         return $this->menu_class;
  163.     }
  164.     public function setMenuClass(?string $menu_class): self
  165.     {
  166.         $this->menu_class $menu_class;
  167.         return $this;
  168.     }
  169.     public function getImages(): ?string
  170.     {
  171.         return $this->images;
  172.     }
  173.     public function setImages(?string $images): self
  174.     {
  175.         $this->images $images;
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return Collection<int, Category>
  180.      */
  181.     public function getCategories(): Collection
  182.     {
  183.         return $this->categories;
  184.     }
  185.     public function addCategory(Category $category): static
  186.     {
  187.         if (!$this->categories->contains($category)) {
  188.             $this->categories->add($category);
  189.             $category->addPage($this);
  190.         }
  191.         return $this;
  192.     }
  193.     public function removeCategory(Category $category): static
  194.     {
  195.         if ($this->categories->removeElement($category)) {
  196.             $category->removePage($this);
  197.         }
  198.         return $this;
  199.     }
  200. }