src/Entity/PageBlock.php line 61

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use ApiPlatform\Metadata\ApiResource,
  5.     ApiPlatform\Metadata\Get,
  6.     ApiPlatform\Metadata\GetCollection,
  7.     ApiPlatform\Metadata\Post,
  8.     ApiPlatform\Metadata\Put,
  9.     ApiPlatform\Metadata\Delete,
  10.     ApiPlatform\Metadata\ApiFilter,
  11.     ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  12. use App\Doctrine\Attribute\TargetEntity,
  13.     App\Security\Voter\PageVoter,
  14.     App\Repository\PageBlockRepository;
  15. use App\Enum\BlockType,
  16.     App\Lib\Actions,
  17.     App\Filter\IriFilter;
  18. #[ApiResource(
  19.     description'Page blocks',
  20.     normalizationContext: ['groups' => [
  21.         'read',
  22.         'read:' self::class,
  23.         'read:' self::class . 'Translation',
  24.         'read:' AbstractThumb::class,
  25.         'read:' AbstractBlock::class,
  26.         'read:' AbstractBlockTranslation::class,
  27.         'read:' AbstractBlockTranslationLogo::class,
  28.         'read:' AbstractBlockTranslationFile::class
  29.     ]],
  30.     denormalizationContext: ['groups' => ['write']],
  31.     security'is_granted("' Page::class . '")',
  32.     order: ['ord' => 'desc'],
  33.     operations: [
  34.         new GetCollection(),
  35.         new Post(
  36.             denormalizationContext: ['groups' => ['write',  'post']],
  37.             securityPostDenormalize'is_granted("' Actions::CREATE '", object)',
  38.             securityPostDenormalizeMessagePageVoter::EDIT_MESSAGE
  39.         ),
  40.         new Get(),
  41.         new Put(
  42.             securityPostDenormalize'is_granted("' Actions::EDIT '", object)',
  43.             securityPostDenormalizeMessagePageVoter::EDIT_MESSAGE
  44.         ),
  45.         new Delete(
  46.             securityPostDenormalize'is_granted("' Actions::DELETE '", object)',
  47.             securityPostDenormalizeMessagePageVoter::EDIT_MESSAGE
  48.         ),
  49.     ],
  50.     extraProperties: ['standard_put' => false],
  51. )]
  52. #[ApiFilter(IriFilter::class, properties: ['parent'])]
  53. #[ApiFilter(OrderFilter::class, properties: ['ord'])]
  54. #[TargetEntity(mappings: ['parent' => Page::class])]
  55. #[ORM\Entity(repositoryClassPageBlockRepository::class)]
  56. class PageBlock extends AbstractBlock
  57. {
  58.     public function __construct(Page $parentBlockType $type)
  59.     {
  60.         parent::__construct($parent$type);
  61.     }
  62. }