src/Entity/JournalBannerTranslation.php line 22

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Serializer\Annotation\Groups,
  5.     Symfony\Component\Validator\Constraints as Assert;
  6. use ApiPlatform\Metadata\ApiProperty,
  7.     ApiPlatform\Metadata\ApiResource,
  8.     ApiPlatform\Metadata\Get;
  9. use App\Enum\Language,
  10.     App\Repository\JournalBannerTranslationRepository;
  11. #[ApiResource(
  12.     security'is_granted("' Journal::class . '")',
  13.     operations: [ new Get() ],
  14.     extraProperties: ['standard_put' => false],
  15. )]
  16. #[ORM\Entity(repositoryClassJournalBannerTranslationRepository::class)]
  17. class JournalBannerTranslation extends AbstractBannerTranslation
  18. {
  19.     #[ApiProperty(description'Page'writableLinkfalse)]
  20.     #[Groups(['read:' self::class, 'write'])]
  21.     #[Assert\Expression(
  22.         expression'!value || value.getParent() === this.getParent().getParent()',
  23.         message'Cannot assign page from the outside of current journal.'
  24.     )]
  25.     #[ORM\ManyToOne(targetEntityJournalPage::class)]
  26.     #[ORM\JoinColumn(onDelete'set null')]
  27.     private ?JournalPage $page null;
  28.     public function __construct(JournalBanner $parentLanguage $lang)
  29.     {
  30.         parent::__construct($parent$lang);
  31.     }
  32.     public function getPage(): ?JournalPage
  33.     {
  34.         return $this->page;
  35.     }
  36.     public function setPage(?JournalPage $page): self
  37.     {
  38.         if ($page) {
  39.             $this->link null;
  40.         }
  41.         $this->page $page;
  42.         return $this;
  43.     }
  44.     public function setLink(?string $link): self
  45.     {
  46.         if (empty($link)) {
  47.             $this->page null;
  48.         }
  49.         $this->link $link;
  50.         return $this;
  51.     }
  52. }