src/Entity/Report.php line 44

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 App\Trait\TimestampableEntity;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Ramsey\Uuid\Uuid;
  11. use Ramsey\Uuid\UuidInterface;
  12. /**
  13.  * A Report generated by governmental or non-governmental organization.
  14.  *
  15.  * @see https://schema.org/Report
  16.  *
  17.  * @author Jordi Fernandes Alves <jfadev@gmail.com>
  18.  */
  19. #[ORM\Entity]
  20. #[ApiResource(
  21.     iri'Report',
  22.     itemOperations: [
  23.         'get' => ['normalization_context' => ['groups' => 'report:item:get']],
  24.         'put' => [
  25.             'normalization_context' => ['groups' => 'report:item:put'],
  26.             'denormalization_context' => ['groups' => 'report:item:put'],
  27.         ],
  28.         'delete' => [],
  29.     ],
  30.     collectionOperations: [
  31.         'get' => [
  32.             'normalization_context' => ['groups' => 'report:collection:get'],
  33.         ],
  34.         'post' => [
  35.             'normalization_context' => ['groups' => 'report:collection:post'],
  36.             'denormalization_context' => ['groups' => 'report:collection:post'],
  37.         ],
  38.     ],
  39. )]
  40. class Report
  41. {
  42.     use TimestampableEntity;
  43.     
  44.     #[ORM\Id]
  45.     #[ORM\GeneratedValue(strategy'NONE')]
  46.     #[ORM\Column(type'uuid'uniquetrue)]
  47.     #[ApiProperty(iri'https://schema.org/identifier')]
  48.     #[Groups(['report:collection:get''report:item:get'])]
  49.     private ?UuidInterface $id null;
  50.     #[ORM\Column(type'string'nullablefalse)]
  51.     #[Assert\NotNull]
  52.     #[Assert\Type('string')]
  53.     #[ApiProperty(iri'https://schema.org/name')]
  54.     #[Groups(['report:collection:get''report:collection:post''report:item:get''report:item:put'])]
  55.     private ?string $reportName null;
  56.     #[ORM\Column(type'string'nullablefalse)]
  57.     #[Assert\NotNull]
  58.     #[Assert\Type('string')]
  59.     #[ApiProperty(iri'https://schema.org/Text')]
  60.     #[Groups(['report:collection:get''report:collection:post''report:item:get''report:item:put'])]
  61.     private ?string $reportType null;
  62.     #[ORM\Column(type'json'nullablefalse)]
  63.     #[Assert\NotNull]
  64.     #[ApiProperty(iri'https://schema.org/Text')]
  65.     #[Groups(['report:collection:get''report:collection:post''report:item:get''report:item:put'])]
  66.     private ?array $data null;
  67.     #[ORM\Column(type'json'nullablefalse)]
  68.     #[Assert\NotNull]
  69.     #[ApiProperty(iri'https://schema.org/Text')]
  70.     #[Groups(['report:collection:get''report:collection:post''report:item:get''report:item:put'])]
  71.     private ?array $filters null;
  72.     #[ApiProperty(iri'https://schema.org/Person')]
  73.     #[Groups(['report:collection:get''report:collection:post''report:item:get''report:item:put'])]
  74.     private ?User $generatedBy null;
  75.     public function __construct()
  76.     {
  77.         $this->id Uuid::uuid4();
  78.     }
  79.     public function getId(): ?UuidInterface
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function setReportName(?string $reportName): void
  84.     {
  85.         $this->reportName $reportName;
  86.     }
  87.     public function getReportName(): ?string
  88.     {
  89.         return $this->reportName;
  90.     }
  91.     public function setReportType(?string $reportType): void
  92.     {
  93.         $this->reportType $reportType;
  94.     }
  95.     public function getReportType(): ?string
  96.     {
  97.         return $this->reportType;
  98.     }
  99.     public function setData(?array $data): void
  100.     {
  101.         $this->data $data;
  102.     }
  103.     public function getData(): ?array
  104.     {
  105.         return $this->data;
  106.     }
  107.     public function setFilters(?array $filters): void
  108.     {
  109.         $this->filters $filters;
  110.     }
  111.     public function getFilters(): ?array
  112.     {
  113.         return $this->filters;
  114.     }
  115.     public function setGeneratedBy(?User $generatedBy): void
  116.     {
  117.         $this->generatedBy $generatedBy;
  118.     }
  119.     public function getGeneratedBy(): ?User
  120.     {
  121.         return $this->generatedBy;
  122.     }
  123. }