src/Containers/CrmSection/TaskContainer/Entities/TaskCommentEntity.php line 82

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CrmSection\TaskContainer\Entities;
  3. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  4. use ApiPlatform\Metadata\ApiFilter;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use ApiPlatform\Metadata\Link;
  10. use ApiPlatform\Metadata\Post;
  11. use App\Containers\CrmSection\TaskContainer\Data\Repositories\TaskCommentRepository;
  12. use App\Ship\Entities\CommentEntity;
  13. use Doctrine\DBAL\Types\Types;
  14. #[ORM\Entity(repositoryClassTaskCommentRepository::class)]
  15. #[ApiResource(
  16.     routePrefix'/crm',
  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'/task/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'CRM_Tasks'
  58. )]
  59. #[ApiResource(
  60.     uriTemplate'/crm/task/{taskId}/comment',
  61.     uriVariables: [
  62.         'taskId' => new Link(fromClassTaskEntity::class, toProperty'entity'identifiers:['id']),
  63.     ],
  64.     operations: [ new GetCollection() ],
  65.     security"is_granted('ROLE_ADMIN')",
  66.     shortName'CRM_Tasks',
  67.     normalizationContext: ['groups' => ['read'], 'enable_max_depth' => true]
  68. )]
  69. // #[ApiResource(
  70. //     uriTemplate: 'sale/task/{taskId}/comment',
  71. //     uriVariables: [
  72. //         'taskId' => new Link(fromClass: TaskEntity::class, toProperty: 'entity'),
  73. //     ],
  74. //     operations: [ new Post() ],
  75. //     shortName: 'Sale'
  76. // )]
  77. #[ApiFilter(OrderFilter::class)]
  78. class TaskCommentEntity extends CommentEntity
  79. {
  80.     #[ORM\ManyToOne(targetEntityTaskEntity::class)]
  81.     #[ORM\JoinColumn(name'entity'referencedColumnName'id')]
  82.     #[Groups(['read'])]
  83.     private TaskEntity|null $entity null;
  84.     /**
  85.      * Get the value of entity
  86.      */
  87.     public function getEntity(): ?TaskEntity
  88.     {
  89.         return $this->entity;
  90.     }
  91.     /**
  92.      * Set the value of entity
  93.      */
  94.     public function setEntity(?TaskEntity $entity): self
  95.     {
  96.         $this->entity $entity;
  97.         return $this;
  98.     }
  99. }