src/Entity/IncidentCategory.php line 43

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 Symfony\Component\Serializer\Annotation\Groups;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Ramsey\Uuid\Uuid;
  10. use Ramsey\Uuid\UuidInterface;
  11. /**
  12.  * The most generic type of item.
  13.  *
  14.  * @see https://schema.org/Thing
  15.  *
  16.  * @author Jordi Fernandes Alves <jfadev@gmail.com>
  17.  */
  18. #[ORM\Entity]
  19. #[ApiResource(   
  20.     iri'IncidentCategory',
  21.     itemOperations: [
  22.         'get' => ['normalization_context' => ['groups' => 'incident_category:item:get']],
  23.         'put' => [
  24.             'normalization_context' => ['groups' => 'incident_category:item:put'],
  25.             'denormalization_context' => ['groups' => 'incident_category:item:put'],
  26.         ],
  27.         'delete' => [],
  28.     ],
  29.     collectionOperations: [
  30.         'get' => [
  31.             'normalization_context' => ['groups' => 'incident_category:collection:get'],
  32.         ],
  33.         'post' => [
  34.             'normalization_context' => ['groups' => 'incident_category:collection:post'],
  35.             'denormalization_context' => ['groups' => 'incident_category:collection:post'],
  36.         ],
  37.     ],
  38. )]
  39. class IncidentCategory
  40. {
  41.     use TimestampableEntity;
  42.     
  43.     #[ORM\Id]
  44.     #[ORM\GeneratedValue(strategy'NONE')]
  45.     #[ORM\Column(type'uuid'uniquetrue)]
  46.     #[ApiProperty(iri'https://schema.org/identifier')]
  47.     #[Groups(['incident_category:item:get''incident_category:collection:get'])]
  48.     private ?UuidInterface $id null;
  49.     /**
  50.      * @var string|null the name of the item
  51.      *
  52.      * @see https://schema.org/name
  53.      */
  54.     #[ORM\Column(type'string'nullablefalse)]
  55.     #[ApiProperty(iri'https://schema.org/name')]
  56.     #[Groups(['incident_category:item:get''incident_category:collection:get''incident_category:collection:post'])]
  57.     private ?string $name null;
  58.     public function __construct()
  59.     {
  60.         $this->id Uuid::uuid4();
  61.     }
  62.     public function getId(): ?UuidInterface
  63.     {
  64.         return $this->id;
  65.     }
  66.     /**
  67.      * @param string|null $name
  68.      */
  69.     public function setName(?string $name): void
  70.     {
  71.         $this->name $name;
  72.     }
  73.     /**
  74.      * @return string|null
  75.      */
  76.     public function getName(): ?string
  77.     {
  78.         return $this->name;
  79.     }
  80. }