src/Entity/FooterMenuGroupItemTranslation.php line 28

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use ApiPlatform\Metadata\ApiResource,
  7.     ApiPlatform\Metadata\ApiProperty,
  8.     ApiPlatform\Metadata\Get;
  9. use App\Entity\Trait\IdTrait,
  10.     App\Entity\Trait\UuidTrait,
  11.     App\Entity\Trait\TimestampableTrait,
  12.     App\Entity\Trait\TranslationTrait,
  13.     App\Entity\Interface\TranslationInterface,
  14.     App\Enum\Language;
  15. use App\Repository\FooterMenuGroupItemTranslationRepository;
  16. #[ApiResource(
  17.     security'is_granted("' FooterMenuGroup::class . '")',
  18.     operations: [ new Get() ],
  19.     extraProperties: ['standard_put' => false],
  20. )]
  21. #[ORM\Entity(repositoryClassFooterMenuGroupItemTranslationRepository::class)]
  22. class FooterMenuGroupItemTranslation implements TranslationInterface
  23. {
  24.     use IdTrait,
  25.         UuidTrait,
  26.         TimestampableTrait,
  27.         TranslationTrait;
  28.     #[ApiProperty(description'Title')]
  29.     #[Groups(['read''write'])]
  30.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  31.     private ?string $title null;
  32.     #[ApiProperty(description'Link')]
  33.     #[Groups(['read:' self::class, 'write'])]
  34.     #[ORM\Column(typeTypes::STRINGlength1023nullabletrue)]
  35.     private ?string $link null;
  36.     #[ApiProperty(description'Page'writableLinkfalse)]
  37.     #[Groups(['read:' self::class, 'write'])]
  38.     #[ORM\ManyToOne(targetEntityPage::class)]
  39.     #[ORM\JoinColumn(onDelete'set null')]
  40.     private ?Page $page null;
  41.     public function __construct(FooterMenuGroupItem $parentLanguage $lang)
  42.     {
  43.         $this->setUuid();
  44.         $this->parent $parent;
  45.         $this->lang $lang;
  46.         $this->createdAt = new \DateTimeImmutable();
  47.         $this->updatedAt = new \DateTimeImmutable();
  48.         $parent->addTranslation($this);
  49.     }
  50.     public function getTitle(): ?string
  51.     {
  52.         return $this->title;
  53.     }
  54.     public function setTitle(?string $title): self
  55.     {
  56.         $this->title $title;
  57.         return $this;
  58.     }
  59.     public function getLink(): ?string
  60.     {
  61.         return $this->link;
  62.     }
  63.     public function setLink(?string $link): self
  64.     {
  65.         if (empty($link)) {
  66.             $this->page null;
  67.         }
  68.         $this->link $link;
  69.         return $this;
  70.     }
  71.     public function getPage(): ?Page
  72.     {
  73.         return $this->page;
  74.     }
  75.     public function setPage(?Page $page): self
  76.     {
  77.         if ($page) {
  78.             $this->link null;
  79.         }
  80.         $this->page $page;
  81.         return $this;
  82.     }
  83.     public function getIsLinkable(): bool
  84.     {
  85.         return ! empty($this->link) || $this->page !== null;
  86.     }
  87. }