src/Entity/PageBlock.php line 61
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\GetCollection,
ApiPlatform\Metadata\Post,
ApiPlatform\Metadata\Put,
ApiPlatform\Metadata\Delete,
ApiPlatform\Metadata\ApiFilter,
ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use App\Doctrine\Attribute\TargetEntity,
App\Security\Voter\PageVoter,
App\Repository\PageBlockRepository;
use App\Enum\BlockType,
App\Lib\Actions,
App\Filter\IriFilter;
#[ApiResource(
description: 'Page blocks',
normalizationContext: ['groups' => [
'read',
'read:' . self::class,
'read:' . self::class . 'Translation',
'read:' . AbstractThumb::class,
'read:' . AbstractBlock::class,
'read:' . AbstractBlockTranslation::class,
'read:' . AbstractBlockTranslationLogo::class,
'read:' . AbstractBlockTranslationFile::class
]],
denormalizationContext: ['groups' => ['write']],
security: 'is_granted("' . Page::class . '")',
order: ['ord' => 'desc'],
operations: [
new GetCollection(),
new Post(
denormalizationContext: ['groups' => ['write', 'post']],
securityPostDenormalize: 'is_granted("' . Actions::CREATE . '", object)',
securityPostDenormalizeMessage: PageVoter::EDIT_MESSAGE
),
new Get(),
new Put(
securityPostDenormalize: 'is_granted("' . Actions::EDIT . '", object)',
securityPostDenormalizeMessage: PageVoter::EDIT_MESSAGE
),
new Delete(
securityPostDenormalize: 'is_granted("' . Actions::DELETE . '", object)',
securityPostDenormalizeMessage: PageVoter::EDIT_MESSAGE
),
],
extraProperties: ['standard_put' => false],
)]
#[ApiFilter(IriFilter::class, properties: ['parent'])]
#[ApiFilter(OrderFilter::class, properties: ['ord'])]
#[TargetEntity(mappings: ['parent' => Page::class])]
#[ORM\Entity(repositoryClass: PageBlockRepository::class)]
class PageBlock extends AbstractBlock
{
public function __construct(Page $parent, BlockType $type)
{
parent::__construct($parent, $type);
}
}