src/Entity/IndicatorType.php line 48

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Serializer\Annotation\Groups,
  6.     Symfony\Component\Validator\Constraints as Assert;
  7. use ApiPlatform\Metadata\ApiResource,
  8.     ApiPlatform\Metadata\ApiProperty,
  9.     ApiPlatform\Metadata\Get,
  10.     ApiPlatform\Metadata\GetCollection,
  11.     ApiPlatform\Metadata\Post,
  12.     ApiPlatform\Metadata\Put,
  13.     ApiPlatform\Metadata\Delete,
  14.     ApiPlatform\Metadata\ApiFilter,
  15.     ApiPlatform\Doctrine\Orm\Filter\SearchFilter,
  16.     ApiPlatform\Doctrine\Orm\Filter\BooleanFilter,
  17.     ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  18. use App\Entity\Trait\IdTrait,
  19.     App\Entity\Trait\UuidTrait,
  20.     App\Entity\Trait\OrdStatTrait,
  21.     App\Entity\Trait\TimestampableTrait,
  22.     App\Entity\Interface\OrdStatableInterface,
  23.     App\Repository\IndicatorTypeRepository;
  24. #[ApiResource(
  25.     description'Indicator types',
  26.     normalizationContext: ['groups' => ['read''read:' self::class]],
  27.     denormalizationContext: ['groups' => ['write']],
  28.     security'is_granted("' self::class . '")',
  29.     order: ['ord' => 'desc'],
  30.     operations: [
  31.         new GetCollection(),
  32.         new Post(),
  33.         new Get(),
  34.         new Put(),
  35.         new Delete(),
  36.     ],
  37.     extraProperties: ['standard_put' => false],
  38. )]
  39. #[ApiFilter(SearchFilter::class, properties: ['title' => 'partial'])]
  40. #[ApiFilter(BooleanFilter::class, properties: ['stat'])]
  41. #[ApiFilter(OrderFilter::class, properties: ['ord'])]
  42. #[ORM\Entity(repositoryClassIndicatorTypeRepository::class)]
  43. class IndicatorType implements OrdStatableInterface
  44. {
  45.     use IdTrait,
  46.         UuidTrait,
  47.         OrdStatTrait,
  48.         TimestampableTrait;
  49.     #[ApiProperty(description'Title')]
  50.     #[Groups(['read''write'])]
  51.     #[Assert\NotBlank]
  52.     #[ORM\Column(typeTypes::STRINGlength511uniquetrue)]
  53.     private string $title;
  54.     public function __construct(string $title)
  55.     {
  56.         $this->setUuid();
  57.         $this->title $title;
  58.         $this->createdAt = new \DateTimeImmutable();
  59.         $this->updatedAt = new \DateTimeImmutable();
  60.     }
  61.     public function getTitle(): string
  62.     {
  63.         return $this->title;
  64.     }
  65.     public function setTitle(string $title): self
  66.     {
  67.         $this->title $title;
  68.         return $this;
  69.     }
  70. }