src/Entity/Pages.php line 47

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Patch;
  8. use ApiPlatform\Metadata\Post;
  9. use App\Controller\PagesController;
  10. use App\Entity\Traits\CreatedAtTrait;
  11. use App\Entity\Traits\UpdatedAtTrait;
  12. use App\Repository\PagesRepository;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. #[ORM\HasLifecycleCallbacks]
  18. #[ORM\Entity(repositoryClassPagesRepository::class)]
  19. #[ApiResource(
  20.     operations: [
  21.         new GetCollection(
  22.             normalizationContext: ['groups' => ['pages:read']],
  23.         ),
  24.         new Post(
  25.             denormalizationContext: ['groups' => ['pages:write']]
  26.         ),
  27.         new Get(
  28.             uriTemplate'/user/pages/{id}',
  29.             normalizationContext: ['groups' => ['page:read']],
  30.             security"is_granted('ROLE_USER')",
  31.         ),
  32.         new Get(
  33.             uriTemplate'pagesCopy/{id}',
  34.             controllerPagesController::class,
  35.             normalizationContext: ['groups' => ['page:read']]
  36.         ),
  37.         new Patch(
  38.             denormalizationContext: ['groups' => ['pages:update']]
  39.         ),
  40.         new Delete()
  41.     ],
  42.     paginationEnabledfalse
  43. )]
  44. class Pages
  45. {
  46.     use CreatedAtTrait;
  47.     use UpdatedAtTrait;
  48.     #[ORM\Id]
  49.     #[ORM\GeneratedValue]
  50.     #[ORM\Column]
  51.     #[Groups(['pages:read''projects:read''page:read',])]
  52.     private ?int $id null;
  53.     #[ORM\Column(length255nullabletrue)]
  54.     #[Groups(['pages:write''pages:update''pages:read''projects:read''page:read',])]
  55.     private ?string $title null;
  56.     #[ORM\Column(nullabletrue)]
  57.     #[Groups(['pages:write''pages:update''page:read',])]
  58.     private array $children = [];
  59.     #[ORM\ManyToOne(inversedBy'pages')]
  60.     #[Groups(['pages:write''page:read',])]
  61.     private ?Projects $project null;
  62.     #[ORM\Column]
  63.     #[Groups(['pages:write''pages:update''page:read',])]
  64.     private ?bool $isActive true;
  65.     #[ORM\Column]
  66.     #[Groups(['pages:write''pages:update''pages:read''projects:read''page:read',])]
  67.     private ?bool $isMain false;
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getTitle(): ?string
  73.     {
  74.         return $this->title;
  75.     }
  76.     public function setTitle(?string $title): static
  77.     {
  78.         $this->title $title;
  79.         return $this;
  80.     }
  81.     public function getChildren(): array
  82.     {
  83.         return $this->children;
  84.     }
  85.     public function setChildren(array $children): static
  86.     {
  87.         $this->children $children;
  88.         return $this;
  89.     }
  90.     public function getProject(): ?Projects
  91.     {
  92.         return $this->project;
  93.     }
  94.     public function setProject(?Projects $project): static
  95.     {
  96.         $this->project $project;
  97.         return $this;
  98.     }
  99.     public function isIsActive(): ?bool
  100.     {
  101.         return $this->isActive;
  102.     }
  103.     public function setIsActive(bool $isActive): static
  104.     {
  105.         $this->isActive $isActive;
  106.         return $this;
  107.     }
  108.     public function isIsMain(): ?bool
  109.     {
  110.         return $this->isMain;
  111.     }
  112.     public function setIsMain(bool $isMain): static
  113.     {
  114.         $this->isMain $isMain;
  115.         return $this;
  116.     }
  117. }