src/Entity/Redactor.php line 44

  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. #[ApiResource(
  16.     description'Redactors',
  17.     normalizationContext: ['groups' => [
  18.         'read',
  19.         'read:' self::class,
  20.         'read:' self::class . 'Translation',
  21.         'read:' AbstractAuthor::class,
  22.         'read:' AbstractAuthor::class . 'Translation'
  23.     ]],
  24.     denormalizationContext: ['groups' => ['write']],
  25.     security'is_granted("' self::class . '")',
  26.     order: ['ord' => 'desc'],
  27.     operations: [
  28.         new GetCollection(),
  29.         new Post(),
  30.         new Get(
  31.             normalizationContext: ['groups' => [
  32.                 'read',
  33.                 'read:' self::class,
  34.                 'read:' self::class . 'Translation',
  35.                 'read:' AbstractAuthor::class,
  36.                 'read:' AbstractAuthor::class . 'Translation',
  37.                 'read:redactor'
  38.             ]]
  39.         ),
  40.         new Put(),
  41.         new Delete(
  42.             securityPostDenormalize'is_granted("' Actions::DELETE '", object)',
  43.             securityPostDenormalizeMessageArchivableVoter::MESSAGE
  44.         ),
  45.     ],
  46.     extraProperties: ['standard_put' => false],
  47. )]
  48. #[ORM\Entity(repositoryClassRedactorRepository::class)]
  49. class Redactor extends AbstractAuthor
  50. {
  51.     #[ApiProperty(description'Import id of employee from old database')]
  52.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  53.     protected ?int $importEmployeeId null;
  54.     public function getImportEmployeeId(): ?int
  55.     {
  56.         return $this->importEmployeeId;
  57.     }
  58.     public function setImportEmployeeId(?int $importEmployeeId): self
  59.     {
  60.         $this->importEmployeeId $importEmployeeId;
  61.         return $this;
  62.     }
  63.     public function getType(): string
  64.     {
  65.         return 'redactor';
  66.     }
  67. }