src/Entity/Banner.php line 44

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  5. use ApiPlatform\Metadata\ApiResource,
  6.     ApiPlatform\Metadata\Get,
  7.     ApiPlatform\Metadata\GetCollection,
  8.     ApiPlatform\Metadata\Post,
  9.     ApiPlatform\Metadata\Put,
  10.     ApiPlatform\Metadata\Delete;
  11. use App\Entity\Trait\Languages\SiteLanguagesTrait,
  12.     App\Entity\Interface\LanguageableInterface,
  13.     App\Repository\BannerRepository,
  14.     App\Enum\Language;
  15. #[ApiResource(
  16.     description'Banners',
  17.     normalizationContext: ['groups' => [
  18.         'read',
  19.         'read:' self::class,
  20.         'read:' self::class . 'Translation',
  21.         'read:' AbstractBanner::class,
  22.         'read:' AbstractBannerTranslation::class
  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.         new Put(),
  32.         new Delete(),
  33.     ],
  34.     extraProperties: ['standard_put' => false],
  35. )]
  36. #[UniqueEntity(fields: ['workingTitle'], message'This working title already exists.')]
  37. #[ORM\UniqueConstraint(fields: ['workingTitle'])]
  38. #[ORM\Entity(repositoryClassBannerRepository::class)]
  39. class Banner extends AbstractBanner implements LanguageableInterface
  40. {
  41.     use SiteLanguagesTrait;
  42.     public function __construct(string $workingTitle, ?array $languages)
  43.     {
  44.         parent::__construct($workingTitle);
  45.         $this->setLanguages($languages ?? Language::DEFAULT_SITE);
  46.     }
  47. }