src/Containers/OscpvSection/ContractContainer/Entities/ContractCommentEntity.php line 74

Open in your IDE?
  1. <?php
  2. namespace App\Containers\OscpvSection\ContractContainer\Entities;
  3. use Symfony\Component\Serializer\Annotation\Groups;
  4. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\GetCollection;
  8. use ApiPlatform\Metadata\Link;
  9. use ApiPlatform\Metadata\Post;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Doctrine\DBAL\Types\Types;
  12. use App\Ship\Entities\CommentEntity;
  13. use App\Containers\OscpvSection\ContractContainer\Data\Repositories\ContractCommentRepository;
  14. use App\Containers\OscpvSection\ContractContainer\Entities\ContractEntity;
  15. #[ApiResource(
  16.     routePrefix'/oscpv',
  17.     security"is_granted('ROLE_ADMIN') or is_granted('ROLE_READONLY')",
  18.     operations: [
  19.         // new GetCollection(
  20.         //     uriTemplate: '/comments',
  21.         //     openapiContext: [
  22.         //         "summary" => ""
  23.         //     ]
  24.         // ),
  25.         // new Get(
  26.         //     uriTemplate: '/comment/{id}',
  27.         //     openapiContext: [
  28.         //         "summary" => ""
  29.         //     ]
  30.         // ),
  31.         new Post(
  32.             uriTemplate'/contract/comment',
  33.             openapiContext: [
  34.                 "summary" => ""
  35.             ]
  36.         ),
  37.         // new Patch(
  38.         //     uriTemplate: '/comment/{id}',
  39.         //     openapiContext: [
  40.         //         "summary" => ""
  41.         //     ]
  42.         // ),
  43.         // new Put(
  44.         //     uriTemplate: '/comment/{id}',
  45.         //     openapiContext: [
  46.         //         "summary" => ""
  47.         //     ]
  48.         // ),
  49.         // new Delete(
  50.         //     uriTemplate: '/comment/{id}',
  51.         //     openapiContext: [
  52.         //         "summary" => ""
  53.         //     ]
  54.         // )
  55.     ],
  56.     normalizationContext: ['groups' => ['read']],
  57.     shortName'OSCPV_Contracts'
  58. )]
  59. #[ApiResource(
  60.     uriTemplate'/oscpv/contract/{contractId}/comment',
  61.     uriVariables: [
  62.         'contractId' => new Link(fromClassContractEntity::class, toProperty'entity'identifiers:['id']),
  63.     ],
  64.     operations: [ new GetCollection() ],
  65.     security"is_granted('ROLE_ADMIN')",
  66.     shortName'OSCPV_Contracts',
  67.     normalizationContext: ['groups' => ['read'], 'enable_max_depth' => true]
  68. )]
  69. #[ApiFilter(OrderFilter::class)]
  70. #[ORM\Entity(repositoryClassContractCommentRepository::class)]
  71. class ContractCommentEntity extends CommentEntity
  72. {
  73.     #[ORM\ManyToOne(targetEntityContractEntity::class)]
  74.     #[ORM\JoinColumn(name'entity'referencedColumnName'id')]
  75.     #[Groups(['read'])]
  76.     private ContractEntity|null $entity null;
  77.     
  78.     public function getEntity(): ?ContractEntity
  79.     {
  80.         return $this->entity;
  81.     }
  82.     public function setEntity(?ContractEntity $entity): self
  83.     {
  84.         $this->entity $entity;
  85.         return $this;
  86.     }
  87. }