src/Entity/Banner.php line 44
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\GetCollection,
ApiPlatform\Metadata\Post,
ApiPlatform\Metadata\Put,
ApiPlatform\Metadata\Delete;
use App\Entity\Trait\Languages\SiteLanguagesTrait,
App\Entity\Interface\LanguageableInterface,
App\Repository\BannerRepository,
App\Enum\Language;
#[ApiResource(
description: 'Banners',
normalizationContext: ['groups' => [
'read',
'read:' . self::class,
'read:' . self::class . 'Translation',
'read:' . AbstractBanner::class,
'read:' . AbstractBannerTranslation::class
]],
denormalizationContext: ['groups' => ['write']],
security: 'is_granted("' . self::class . '")',
order: ['ord' => 'desc'],
operations: [
new GetCollection(),
new Post(),
new Get(),
new Put(),
new Delete(),
],
extraProperties: ['standard_put' => false],
)]
#[UniqueEntity(fields: ['workingTitle'], message: 'This working title already exists.')]
#[ORM\UniqueConstraint(fields: ['workingTitle'])]
#[ORM\Entity(repositoryClass: BannerRepository::class)]
class Banner extends AbstractBanner implements LanguageableInterface
{
use SiteLanguagesTrait;
public function __construct(string $workingTitle, ?array $languages)
{
parent::__construct($workingTitle);
$this->setLanguages($languages ?? Language::DEFAULT_SITE);
}
}