src/Entity/JournalPageTranslation.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\JournalPageTranslationRepository;
  17. use App\Attribute\Sanitizeable,
  18.     App\Enum\Language;
  19. #[ApiResource(
  20.     security'is_granted("' Journal::class . '")',
  21.     operations: [ new Get() ],
  22.     extraProperties: ['standard_put' => false],
  23. )]
  24. #[ORM\Entity(repositoryClassJournalPageTranslationRepository::class)]
  25. class JournalPageTranslation 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.     // in old ejournals sometimes there was description despite linking content from other field,
  42.     // this content was no displayed but still existed in database, maybe if they unlink field?
  43.     #[ApiProperty(description'Old description besides linked text')]
  44.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  45.     private ?string $ignoredDescription null;
  46.     #[ApiProperty(description'Slug')]
  47.     #[Groups(['read:' self::class, 'write'])]
  48.     #[Gedmo\Slug(separator'-'style'default'updatabletruefields: ['title'], uniquefalse)]
  49.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  50.     private ?string $slug null;
  51.     public function __construct(JournalPage $parentLanguage $lang)
  52.     {
  53.         $this->setUuid();
  54.         $this->parent $parent;
  55.         $this->lang $lang;
  56.         $this->createdAt = new \DateTimeImmutable();
  57.         $this->updatedAt = new \DateTimeImmutable();
  58.         $parent->addTranslation($this);
  59.     }
  60.     public function getTitle(): ?string
  61.     {
  62.         return $this->title;
  63.     }
  64.     public function setTitle(?string $title): self
  65.     {
  66.         $this->title $title;
  67.         return $this;
  68.     }
  69.     public function getDescription(): ?string
  70.     {
  71.         return $this->description;
  72.     }
  73.     public function setDescription(?string $description): self
  74.     {
  75.         $this->description $description;
  76.         return $this;
  77.     }
  78.     public function setIgnoredDescription(?string $ignoredDescription): self
  79.     {
  80.         $this->ignoredDescription $ignoredDescription;
  81.         return $this;
  82.     }
  83.     public function getSlug(): ?string
  84.     {
  85.         return $this->slug;
  86.     }
  87.     public function setSlug(?string $slug): self
  88.     {
  89.         $this->slug $slug;
  90.         return $this;
  91.     }
  92.     public function clone(JournalPage $parent): self
  93.     {
  94.         $clone = clone $this;
  95.         $clone->id null;
  96.         $clone->setUuid();
  97.         $clone->slug null;
  98.         $clone->parent $parent;
  99.         $clone->parent->addTranslation($clone);
  100.         $clone->createdAt = new \DateTimeImmutable();
  101.         $clone->updatedAt = new \DateTimeImmutable();
  102.         return $clone;
  103.     }
  104. }