src/Entity/LandingPageTranslation.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use ApiPlatform\Metadata\ApiProperty,
  8.     ApiPlatform\Metadata\ApiResource,
  9.     ApiPlatform\Metadata\Get;
  10. use App\Entity\Trait\IdTrait,
  11.     App\Entity\Trait\UuidTrait,
  12.     App\Entity\Trait\TimestampableTrait,
  13.     App\Entity\Trait\TranslationTrait,
  14.     App\Entity\Trait\SEOTrait,
  15.     App\Entity\Interface\TranslationInterface,
  16.     App\Repository\LandingPageTranslationRepository;
  17. use App\Attribute\Sanitizeable,
  18.     App\Enum\Language;
  19. #[ApiResource(
  20.     security'is_granted("' Landing::class . '")',
  21.     operations: [ new Get() ],
  22.     extraProperties: ['standard_put' => false],
  23. )]
  24. #[ORM\Entity(repositoryClassLandingPageTranslationRepository::class)]
  25. class LandingPageTranslation implements TranslationInterface
  26. {
  27.     use IdTrait,
  28.         UuidTrait,
  29.         TimestampableTrait,
  30.         TranslationTrait,
  31.         SEOTrait;
  32.     #[ApiProperty(description'Title')]
  33.     #[Groups(['read''write'])]
  34.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  35.     private ?string $title null;
  36.     #[ApiProperty(description'Description')]
  37.     #[Groups(['read:' self::class, 'write'])]
  38.     #[Sanitizeable]
  39.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  40.     private ?string $description null;
  41.     #[ApiProperty(description'Slug')]
  42.     #[Groups(['read:' self::class, 'write'])]
  43.     #[Gedmo\Slug(separator'-'style'default'updatabletruefields: ['title'], uniquefalse)]
  44.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  45.     private ?string $slug null;
  46.     public function __construct(LandingPage $parentLanguage $lang)
  47.     {
  48.         $this->setUuid();
  49.         $this->parent $parent;
  50.         $this->lang $lang;
  51.         $this->createdAt = new \DateTimeImmutable();
  52.         $this->updatedAt = new \DateTimeImmutable();
  53.         $parent->addTranslation($this);
  54.     }
  55.     public function getTitle(): ?string
  56.     {
  57.         return $this->title;
  58.     }
  59.     public function setTitle(?string $title): self
  60.     {
  61.         $this->title $title;
  62.         return $this;
  63.     }
  64.     public function getDescription(): ?string
  65.     {
  66.         return $this->description;
  67.     }
  68.     public function setDescription(?string $description): self
  69.     {
  70.         $this->description $description;
  71.         return $this;
  72.     }
  73.     public function getSlug(): ?string
  74.     {
  75.         return $this->slug;
  76.     }
  77.     public function setSlug(?string $slug): self
  78.     {
  79.         $this->slug $slug;
  80.         return $this;
  81.     }
  82.     public function clone(LandingPage $parent): self
  83.     {
  84.         $clone = clone $this;
  85.         $clone->id null;
  86.         $clone->setUuid();
  87.         $clone->slug null;
  88.         $clone->parent $parent;
  89.         $clone->parent->addTranslation($clone);
  90.         $clone->createdAt = new \DateTimeImmutable();
  91.         $clone->updatedAt = new \DateTimeImmutable();
  92.         return $clone;
  93.     }
  94. }