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.     #[Groups(['read''write'])]
  71.     #[ORM\Column(length255nullabletrue)]
  72.     private ?string $title null;
  73.     public function __construct()
  74.     {
  75.         $this->categories = new ArrayCollection();
  76.     }
  77.     
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function getName(): ?string
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function setName(?string $name): self
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     public function getParent(): ?self
  92.     {
  93.         return $this->parent;
  94.     }
  95.     public function setParent(?self $parent): self
  96.     {
  97.         $this->parent $parent;
  98.         return $this;
  99.     }
  100.     public function getSynonym(): ?string
  101.     {
  102.         return $this->synonym;
  103.     }
  104.     public function setSynonym(?string $synonym): self
  105.     {
  106.         $this->synonym $synonym;
  107.         return $this;
  108.     }
  109.     public function getPlace(): ?string
  110.     {
  111.         return $this->place;
  112.     }
  113.     public function setPlace(?string $place): self
  114.     {
  115.         $this->place $place;
  116.         return $this;
  117.     }
  118.     public function getType(): ?string
  119.     {
  120.         return $this->type;
  121.     }
  122.     public function setType(?string $type): self
  123.     {
  124.         $this->type $type;
  125.         return $this;
  126.     }
  127.     public function getContent(): ?string
  128.     {
  129.         return $this->content;
  130.     }
  131.     public function setContent(?string $content): self
  132.     {
  133.         $this->content $content;
  134.         return $this;
  135.     }
  136.     public function getOrders(): ?int
  137.     {
  138.         return $this->orders;
  139.     }
  140.     public function setOrders(int $orders): self
  141.     {
  142.         $this->orders $orders;
  143.         return $this;
  144.     }
  145.     public function getActive(): ?string
  146.     {
  147.         return $this->active;
  148.     }
  149.     public function setActive(?string $active): self
  150.     {
  151.         $this->active $active;
  152.         return $this;
  153.     }
  154.     public function getClickability(): ?string
  155.     {
  156.         return $this->clickability;
  157.     }
  158.     public function setClickability(?string $clickability): self
  159.     {
  160.         $this->clickability $clickability;
  161.         return $this;
  162.     }
  163.     public function getMenuClass(): ?string
  164.     {
  165.         return $this->menu_class;
  166.     }
  167.     public function setMenuClass(?string $menu_class): self
  168.     {
  169.         $this->menu_class $menu_class;
  170.         return $this;
  171.     }
  172.     public function getImages(): ?string
  173.     {
  174.         return $this->images;
  175.     }
  176.     public function setImages(?string $images): self
  177.     {
  178.         $this->images $images;
  179.         return $this;
  180.     }
  181.     /**
  182.      * @return Collection<int, Category>
  183.      */
  184.     public function getCategories(): Collection
  185.     {
  186.         return $this->categories;
  187.     }
  188.     public function addCategory(Category $category): static
  189.     {
  190.         if (!$this->categories->contains($category)) {
  191.             $this->categories->add($category);
  192.             $category->addPage($this);
  193.         }
  194.         return $this;
  195.     }
  196.     public function removeCategory(Category $category): static
  197.     {
  198.         if ($this->categories->removeElement($category)) {
  199.             $category->removePage($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function getTitle(): ?string
  204.     {
  205.         return $this->title;
  206.     }
  207.     public function setTitle(?string $title): static
  208.     {
  209.         $this->title $title;
  210.         return $this;
  211.     }
  212. }