src/Entity/PageTranslation.php line 24

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PageTranslationRepository;
  4. use Doctrine\ORM\Mapping as ORM,
  5.     Doctrine\DBAL\Types\Types;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use ApiPlatform\Metadata\ApiProperty;
  8. use App\Entity\Trait\IdTrait,
  9.     App\Entity\Trait\UuidTrait,
  10.     App\Entity\Trait\TimestampableTrait,
  11.     App\Entity\Trait\TranslationTrait,
  12.     App\Entity\Trait\SEOTrait,
  13.     App\Entity\Trait\SlugTrait,
  14.     App\Entity\Interface\TranslationInterface;
  15. use App\Attribute\Sanitizeable,
  16.     App\Enum\Language;
  17. #[ORM\Entity(repositoryClassPageTranslationRepository::class)]
  18. class PageTranslation implements TranslationInterface
  19. {
  20.     use IdTrait,
  21.         UuidTrait,
  22.         TimestampableTrait,
  23.         TranslationTrait,
  24.         SEOTrait,
  25.         SlugTrait;
  26.     #[ApiProperty(description'Title')]
  27.     #[Groups(['read''write'])]
  28.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  29.     private ?string $title null;
  30.     #[ApiProperty(description'Description')]
  31.     #[Groups(['read''write'])]
  32.     #[Sanitizeable]
  33.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  34.     private ?string $description null;
  35.     public function __construct(Page $parentLanguage $lang)
  36.     {
  37.         $this->setUuid();
  38.         $this->parent $parent;
  39.         $this->lang $lang;
  40.         $this->createdAt = new \DateTimeImmutable();
  41.         $this->updatedAt = new \DateTimeImmutable();
  42.         $parent->addTranslation($this);
  43.     }
  44.     public function getTitle(): ?string
  45.     {
  46.         return $this->title;
  47.     }
  48.     public function setTitle(?string $title): self
  49.     {
  50.         $this->title $title;
  51.         return $this;
  52.     }
  53.     public function getDescription(): ?string
  54.     {
  55.         return $this->description;
  56.     }
  57.     public function setDescription(?string $description): self
  58.     {
  59.         $this->description $description;
  60.         return $this;
  61.     }
  62.     public function clone(Page $parent): self
  63.     {
  64.         $clone = clone $this;
  65.         $clone->id null;
  66.         $clone->setUuid();
  67.         $clone->slug null;
  68.         $clone->parent $parent;
  69.         $clone->parent->addTranslation($clone);
  70.         $clone->createdAt = new \DateTimeImmutable();
  71.         $clone->updatedAt = new \DateTimeImmutable();
  72.         return $clone;
  73.     }
  74. }