src/Entity/NewsBlock.php line 45
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types;
use ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\GetCollection,
ApiPlatform\Metadata\Post,
ApiPlatform\Metadata\Put,
ApiPlatform\Metadata\Delete;
use App\Doctrine\Attribute\TargetEntity,
App\Enum\BlockType,
App\Repository\NewsBlockRepository;
#[ApiResource(
description: 'News 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("' . News::class . '")',
order: ['ord' => 'desc'],
operations: [
new GetCollection(),
new Post(denormalizationContext: ['groups' => ['write', 'post']]),
new Get(),
new Put(),
new Delete(),
],
extraProperties: ['standard_put' => false],
)]
#[TargetEntity(mappings: ['parent' => News::class])]
#[ORM\Entity(repositoryClass: NewsBlockRepository::class)]
class NewsBlock extends AbstractBlock
{
#[ApiProperty(description: 'Import id from old database')]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $importId = null;
public function __construct(News $parent, BlockType $type)
{
parent::__construct($parent, $type);
}
public function getImportId(): ?string
{
return $this->importId;
}
public function setImportId(?string $importId): self
{
$this->importId = $importId;
return $this;
}
}