src/Entity/Redactor.php line 65

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiProperty;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use ApiPlatform\Metadata\ApiResource,
  7.     ApiPlatform\Metadata\Get,
  8.     ApiPlatform\Metadata\GetCollection,
  9.     ApiPlatform\Metadata\Post,
  10.     ApiPlatform\Metadata\Put,
  11.     ApiPlatform\Metadata\Delete;
  12. use App\Repository\RedactorRepository,
  13.     App\Security\Voter\ArchivableVoter,
  14.     App\Lib\Actions;
  15. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  16. use ApiPlatform\Metadata\ApiFilter;
  17. use Symfony\Component\Serializer\Annotation\GroupsSymfony\Component\Validator\Constraints as Assert;
  18. #[ApiResource(
  19.     description'Redactors',
  20.     normalizationContext: ['groups' => [
  21.         'read',
  22.         'read:' self::class,
  23.         'read:' self::class . 'Translation',
  24.         'read:' AbstractAuthor::class,
  25.         'read:' AbstractAuthor::class . 'Translation'
  26.     ]],
  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.             normalizationContext: ['groups' => [
  35.                 'read',
  36.                 'read:' self::class,
  37.                 'read:' self::class . 'Translation',
  38.                 'read:' AbstractAuthor::class,
  39.                 'read:' AbstractAuthor::class . 'Translation',
  40.                 'read:redactor'
  41.             ]]
  42.         ),
  43.         new Put(),
  44.         new Delete(
  45.             securityPostDenormalize'is_granted("' Actions::DELETE '", object)',
  46.             securityPostDenormalizeMessageArchivableVoter::MESSAGE
  47.         ),
  48.     ],
  49.     extraProperties: ['standard_put' => false],
  50. )]
  51. #[ORM\Entity(repositoryClassRedactorRepository::class)]
  52. #[ApiFilter(OrderFilter::class, properties: [
  53.     'name',
  54.     'surname',
  55.     'nameSortKey',
  56.     'surnameSortKey'
  57. ])]
  58. class Redactor extends AbstractAuthor
  59. {
  60.     #[ApiProperty(description'Import id of employee from old database')]
  61.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  62.     protected ?int $importEmployeeId null;
  63.     #[ApiProperty(description'Name')]
  64.     #[Groups(['read''read:stats''write'])]
  65.     #[Assert\NotBlank]
  66.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  67.     protected ?string $name null;
  68.     public function getImportEmployeeId(): ?int
  69.     {
  70.         return $this->importEmployeeId;
  71.     }
  72.     public function setImportEmployeeId(?int $importEmployeeId): self
  73.     {
  74.         $this->importEmployeeId $importEmployeeId;
  75.         return $this;
  76.     }
  77.     public function getType(): string
  78.     {
  79.         return 'redactor';
  80.     }
  81. }