src/Entity/OperationIncident.php line 32

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. #[ORM\Entity]
  13. #[ApiResource(
  14.     iri'OperationIncident',
  15.     collectionOperations: [],
  16.     itemOperations: [
  17.         'get' => [
  18.             'security' => "is_granted('ROLE_USER')",
  19.             'method' => 'GET',
  20.             'path' => '/contracts/operation_reports/incidents/{id}',
  21.             'openapi_context' => [
  22.                 'tags' => ['Contract / OperationReport / OperationIncident']
  23.             ]
  24.         ]
  25.     ],
  26.     attributes: ['pagination_enabled' => false]
  27. )]
  28. class OperationIncident
  29. {
  30.     use TimestampableEntity;
  31.     // public const PORT_CALL_TYPES = [
  32.     //     'Load',
  33.     //     'Discharge'
  34.     // ];
  35.     
  36.     #[ORM\Id]
  37.     #[ORM\GeneratedValue(strategy'NONE')]
  38.     #[ORM\Column(type'uuid'uniquetrue)]
  39.     private ?UuidInterface $id null;
  40.     #[ORM\Column(type'string'nullablefalse)]
  41.     #[ApiProperty()]
  42.     #[Assert\NotBlank]
  43.     #[Assert\Type('string')]
  44.     // #[Assert\Choice(
  45.     //     choices: self::PORT_CALL_TYPES, 
  46.     //     message: 'The type is not valid.'
  47.     // )]
  48.     #[Groups([
  49.         'contract:collection:post'
  50.         'contract:item:get'
  51.         'contract:item:put'
  52.     ])]
  53.     private ?string $category null;
  54.     #[ORM\Column(type'string'nullablefalse)]
  55.     #[ApiProperty()]
  56.     #[Assert\NotBlank]
  57.     #[Assert\Type('string')]
  58.     // #[Assert\Choice(
  59.     //     choices: self::PORT_CALL_TYPES, 
  60.     //     message: 'The type is not valid.'
  61.     // )]
  62.     #[Groups([
  63.         'contract:collection:post'
  64.         'contract:item:get'
  65.         'contract:item:put'
  66.     ])]
  67.     private ?string $subcategory null;
  68.     #[ORM\ManyToOne(
  69.         targetEntityOperationReport::class, 
  70.         inversedBy'operationIncidents'
  71.     )]
  72.     #[ORM\JoinColumn(nullabletrue)]
  73.     private ?OperationReport $operationReport null;
  74.     public function __construct()
  75.     {
  76.         $this->id Uuid::uuid4();
  77.     }
  78.     public function getId(): ?UuidInterface
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function setCategory(?string $category): void
  83.     {
  84.         $this->category $category;
  85.     }
  86.     public function getCategory(): ?string
  87.     {
  88.         return $this->category;
  89.     }
  90.     public function setSubcategory(?string $subcategory): void
  91.     {
  92.         $this->subcategory $subcategory;
  93.     }
  94.     public function getSubcategory(): ?string
  95.     {
  96.         return $this->subcategory;
  97.     }
  98.     public function setOperationReport(?OperationReport $operationReport): void
  99.     {
  100.         $this->operationReport $operationReport;
  101.     }
  102.     public function getOperationReport(): ?OperationReport
  103.     {
  104.         return $this->operationReport;
  105.     }
  106. }