src/Entity/JournalBannerTranslation.php line 22
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups,
Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get;
use App\Enum\Language,
App\Repository\JournalBannerTranslationRepository;
#[ApiResource(
security: 'is_granted("' . Journal::class . '")',
operations: [ new Get() ],
extraProperties: ['standard_put' => false],
)]
#[ORM\Entity(repositoryClass: JournalBannerTranslationRepository::class)]
class JournalBannerTranslation extends AbstractBannerTranslation
{
#[ApiProperty(description: 'Page', writableLink: false)]
#[Groups(['read:' . self::class, 'write'])]
#[Assert\Expression(
expression: '!value || value.getParent() === this.getParent().getParent()',
message: 'Cannot assign page from the outside of current journal.'
)]
#[ORM\ManyToOne(targetEntity: JournalPage::class)]
#[ORM\JoinColumn(onDelete: 'set null')]
private ?JournalPage $page = null;
public function __construct(JournalBanner $parent, Language $lang)
{
parent::__construct($parent, $lang);
}
public function getPage(): ?JournalPage
{
return $this->page;
}
public function setPage(?JournalPage $page): self
{
if ($page) {
$this->link = null;
}
$this->page = $page;
return $this;
}
public function setLink(?string $link): self
{
if (empty($link)) {
$this->page = null;
}
$this->link = $link;
return $this;
}
}