src/Entity/NewsBlock.php line 45

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use ApiPlatform\Metadata\ApiProperty,
  6.     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\Doctrine\Attribute\TargetEntity,
  13.     App\Enum\BlockType,
  14.     App\Repository\NewsBlockRepository;
  15. #[ApiResource(
  16.     description'News blocks',
  17.     normalizationContext: ['groups' => [
  18.         'read',
  19.         'read:' self::class,
  20.         'read:' self::class . 'Translation',
  21.         'read:' AbstractThumb::class,
  22.         'read:' AbstractBlock::class,
  23.         'read:' AbstractBlockTranslation::class,
  24.         'read:' AbstractBlockTranslationLogo::class,
  25.         'read:' AbstractBlockTranslationFile::class
  26.     ]],
  27.     denormalizationContext: ['groups' => ['write']],
  28.     security'is_granted("' News::class . '")',
  29.     order: ['ord' => 'desc'],
  30.     operations: [
  31.         new GetCollection(),
  32.         new Post(denormalizationContext: ['groups' => ['write',  'post']]),
  33.         new Get(),
  34.         new Put(),
  35.         new Delete(),
  36.     ],
  37.     extraProperties: ['standard_put' => false],
  38. )]
  39. #[TargetEntity(mappings: ['parent' => News::class])]
  40. #[ORM\Entity(repositoryClassNewsBlockRepository::class)]
  41. class NewsBlock extends AbstractBlock
  42. {
  43.     #[ApiProperty(description'Import id from old database')]
  44.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  45.     private ?string $importId null;
  46.     public function __construct(News $parentBlockType $type)
  47.     {
  48.         parent::__construct($parent$type);
  49.     }
  50.     public function getImportId(): ?string
  51.     {
  52.         return $this->importId;
  53.     }
  54.     public function setImportId(?string $importId): self
  55.     {
  56.         $this->importId $importId;
  57.         return $this;
  58.     }
  59. }