src/Entity/InsuredInsurerGlobalCcg.php line 74

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use ApiPlatform\Core\Annotation\ApiFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  9. use App\Trait\TimestampableEntity;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Serializer\Annotation\MaxDepth;
  14. #[ORM\Entity]
  15. #[ApiResource(
  16.     iri'InsuredInsurerGlobalCcg',
  17.     itemOperations: [
  18.         'get' => [
  19.             // 'security' => "is_granted('ROLE_USER')",
  20.             'normalization_context' => [
  21.                 'groups' => 'insured_insurer_global_ccg:item:get',
  22.                 'enable_max_depth' => true
  23.             ]
  24.         ],
  25.         'put' => [
  26.             // 'security' => "is_granted('ROLE_USER')",
  27.             'normalization_context' => [
  28.                 'groups' => 'insured_insurer_global_ccg:item:put',
  29.                 'enable_max_depth' => true
  30.             ],
  31.             'denormalization_context' => [
  32.                 'groups' => 'insured_insurer_global_ccg:item:put',
  33.                 'enable_max_depth' => true
  34.             ]
  35.         ],
  36.         'delete' => [
  37.             // 'security' => "is_granted('ROLE_USER')",
  38.         ]
  39.     ],
  40.     collectionOperations: [
  41.         'get' => [
  42.             // 'security' => "is_granted('ROLE_USER')",
  43.             'normalization_context' => [
  44.                 'groups' => ['insured_insurer_global_ccg:collection:get''createdAt'],
  45.                 'enable_max_depth' => true
  46.             ]
  47.         ],
  48.         'post' => [
  49.             // 'security' => "is_granted('ROLE_USER')",
  50.             'normalization_context' => [
  51.                 'groups' => 'insured_insurer_global_ccg:collection:post',
  52.                 'enable_max_depth' => true
  53.             ],
  54.             'denormalization_context' => [
  55.                 'groups' => 'insured_insurer_global_ccg:collection:post',
  56.                 'enable_max_depth' => true
  57.             ]
  58.         ],
  59.     ]
  60. )]
  61. #[ApiFilter(SearchFilter::class, properties: [
  62.     'insuredInsurerGlobal' => 'exact',
  63.     'uploadType',
  64.     'createdAt',
  65. ])]
  66. #[ApiFilter(OrderFilter::class, properties: [
  67.     'uploadType',
  68.     'createdAt',
  69. ])]
  70. class InsuredInsurerGlobalCcg
  71. {
  72.     use TimestampableEntity;
  73.     
  74.     #[ORM\Id]
  75.     #[ORM\GeneratedValue(strategy'AUTO')]
  76.     #[ORM\Column(type'integer')]
  77.     #[Groups([
  78.         'insured_insurer_global_ccg:collection:get',
  79.         'insured_insurer_global_ccg:collection:post',
  80.         'insured_insurer_global_ccg:item:get',
  81.         'insured_insurer_global_ccg:item:put',
  82.     ])]
  83.     private ?int $id null;
  84.     #[ORM\Column(type'string')]
  85.     #[ApiProperty(iri'https://schema.org/Text')]
  86.     #[Assert\Type('string')]
  87.     #[Groups([
  88.         'insured_insurer_global_ccg:collection:get',
  89.         'insured_insurer_global_ccg:collection:post',
  90.         'insured_insurer_global_ccg:item:get',
  91.         'insured_insurer_global_ccg:item:put',
  92.         'insured:item:get',
  93.     ])]
  94.     private ?string $uploadType null;
  95.     #[ORM\ManyToOne(targetEntityInsuredInsurerGlobal::class, inversedBy'ccgs')]
  96.     #[Groups([
  97.         'insured_insurer_global_ccg:collection:get',
  98.         'insured_insurer_global_ccg:collection:post',
  99.         'insured_insurer_global_ccg:item:get',
  100.         'insured_insurer_global_ccg:item:put',
  101.     ])]
  102.     private $insuredInsurerGlobal;
  103.     #[ORM\OneToOne(inversedBy'insuredInsurerGlobalCcg'targetEntityMedia::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  104.     #[Groups([
  105.         'insured_insurer_global_ccg:collection:get',
  106.         'insured_insurer_global_ccg:collection:post',
  107.         'insured_insurer_global_ccg:item:get',
  108.         'insured_insurer_global_ccg:item:put',
  109.     ])]
  110.     private $upload;
  111.     public function getId(): ?int
  112.     {
  113.         return $this->id;
  114.     }
  115.     /**
  116.      * @param string|null $uploadType
  117.      */
  118.     public function setUploadType($uploadType): void
  119.     {
  120.         $this->uploadType $uploadType;
  121.     }
  122.     public function getUploadType(): ?string
  123.     {
  124.         return $this->uploadType;
  125.     }
  126.     public function getInsuredInsurerGlobal(): ?InsuredInsurerGlobal
  127.     {
  128.         return $this->insuredInsurerGlobal;
  129.     }
  130.     public function setInsuredInsurerGlobal(?InsuredInsurerGlobal $insuredInsurerGlobal): self
  131.     {
  132.         $this->insuredInsurerGlobal $insuredInsurerGlobal;
  133.         return $this;
  134.     }
  135.     public function getUpload(): ?Media
  136.     {
  137.         return $this->upload;
  138.     }
  139.     public function setUpload(?Media $upload): self
  140.     {
  141.         $this->upload $upload;
  142.         return $this;
  143.     }
  144. }