<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Trait\TimestampableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* The most generic type of item.
*
* @see https://schema.org/Thing
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'IncidentCategory',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'incident_category:item:get']],
'put' => [
'normalization_context' => ['groups' => 'incident_category:item:put'],
'denormalization_context' => ['groups' => 'incident_category:item:put'],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => ['groups' => 'incident_category:collection:get'],
],
'post' => [
'normalization_context' => ['groups' => 'incident_category:collection:post'],
'denormalization_context' => ['groups' => 'incident_category:collection:post'],
],
],
)]
class IncidentCategory
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ApiProperty(iri: 'https://schema.org/identifier')]
#[Groups(['incident_category:item:get', 'incident_category:collection:get'])]
private ?UuidInterface $id = null;
/**
* @var string|null the name of the item
*
* @see https://schema.org/name
*/
#[ORM\Column(type: 'string', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/name')]
#[Groups(['incident_category:item:get', 'incident_category:collection:get', 'incident_category:collection:post'])]
private ?string $name = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
/**
* @param string|null $name
*/
public function setName(?string $name): void
{
$this->name = $name;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
}