src/Containers/CrmSection/ContractContainer/Entities/ContractCommentEntity.php line 73

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CrmSection\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\CrmSection\ContractContainer\Data\Repositories\ContractCommentRepository;
  14. #[ApiResource(
  15.     routePrefix'/crm',
  16.     security"is_granted('ROLE_ADMIN') or is_granted('ROLE_READONLY')",
  17.     operations: [
  18.         // new GetCollection(
  19.         //     uriTemplate: '/comments',
  20.         //     openapiContext: [
  21.         //         "summary" => ""
  22.         //     ]
  23.         // ),
  24.         // new Get(
  25.         //     uriTemplate: '/comment/{id}',
  26.         //     openapiContext: [
  27.         //         "summary" => ""
  28.         //     ]
  29.         // ),
  30.         new Post(
  31.             uriTemplate'/contract/comment',
  32.             openapiContext: [
  33.                 "summary" => ""
  34.             ]
  35.         ),
  36.         // new Patch(
  37.         //     uriTemplate: '/comment/{id}',
  38.         //     openapiContext: [
  39.         //         "summary" => ""
  40.         //     ]
  41.         // ),
  42.         // new Put(
  43.         //     uriTemplate: '/comment/{id}',
  44.         //     openapiContext: [
  45.         //         "summary" => ""
  46.         //     ]
  47.         // ),
  48.         // new Delete(
  49.         //     uriTemplate: '/comment/{id}',
  50.         //     openapiContext: [
  51.         //         "summary" => ""
  52.         //     ]
  53.         // )
  54.     ],
  55.     normalizationContext: ['groups' => ['read']],
  56.     shortName'CRM_Contracts'
  57. )]
  58. #[ApiResource(
  59.     uriTemplate'/crm/contract/{contractId}/comment',
  60.     uriVariables: [
  61.         'contractId' => new Link(fromClassContractEntity::class, toProperty'entity'identifiers:['id']),
  62.     ],
  63.     operations: [ new GetCollection() ],
  64.     security"is_granted('ROLE_ADMIN')",
  65.     shortName'CRM_Contracts',
  66.     normalizationContext: ['groups' => ['read'], 'enable_max_depth' => true]
  67. )]
  68. #[ApiFilter(OrderFilter::class)]
  69. #[ORM\Entity(repositoryClassContractCommentRepository::class)]
  70. class ContractCommentEntity extends CommentEntity
  71. {
  72.     #[ORM\ManyToOne(targetEntityContractEntity::class)]
  73.     #[ORM\JoinColumn(name'entity'referencedColumnName'id')]
  74.     #[Groups(['read'])]
  75.     private ContractEntity|null $entity null;
  76.     /**
  77.      * Get the value of entity
  78.      */
  79.     public function getEntity(): ?ContractEntity
  80.     {
  81.         return $this->entity;
  82.     }
  83.     /**
  84.      * Set the value of entity
  85.      */
  86.     public function setEntity(?ContractEntity $entity): self
  87.     {
  88.         $this->entity $entity;
  89.         return $this;
  90.     }
  91. }