src/Entity/JournalVolumeTranslation.php line 30

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\JournalUniqueSlugTrait;
  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.     ApiPlatform\Metadata\ApiResource,
  9.     ApiPlatform\Metadata\Get;
  10. use App\Entity\Interface\TranslationInterface,
  11.     App\Entity\Trait\IdTrait,
  12.     App\Entity\Trait\UuidTrait,
  13.     App\Entity\Trait\TimestampableTrait,
  14.     App\Entity\Trait\TranslationTrait;
  15. use App\Enum\Language,
  16.     App\Attribute\Sanitizeable,
  17.     App\Repository\JournalVolumeTranslationRepository;
  18. #[ApiResource(
  19.     security'is_granted("' Journal::class . '")',
  20.     operations: [ new Get() ],
  21.     extraProperties: ['standard_put' => false],
  22. )]
  23. #[ORM\Entity(repositoryClassJournalVolumeTranslationRepository::class)]
  24. class JournalVolumeTranslation implements TranslationInterface
  25. {
  26.     use IdTrait,
  27.         UuidTrait,
  28.         TimestampableTrait,
  29.         TranslationTrait,
  30.         JournalUniqueSlugTrait;
  31.     #[ApiProperty(description'Title')]
  32.     #[Groups(['read''write'])]
  33.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  34.     private ?string $title null;
  35.     #[ApiProperty(description'Subtitle')]
  36.     #[Groups(['read:' self::class, 'write'])]
  37.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  38.     private ?string $subtitle null;
  39.     #[ApiProperty(description'Funding description')]
  40.     #[Groups(['read:' self::class, 'write'])]
  41.     #[Sanitizeable]
  42.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  43.     private ?string $fundingDescription null;
  44.     #[ApiProperty(description'Meta title')]
  45.     #[Groups(['read:' self::class, 'write'])]
  46.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  47.     private ?string $metaTitle null;
  48.     #[ApiProperty(description'Meta description')]
  49.     #[Groups(['read:' self::class, 'write'])]
  50.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  51.     private ?string $metaDescription null;
  52.     #[ApiProperty(description'Meta keywords')]
  53.     #[Groups(['read:' self::class, 'write'])]
  54.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  55.     private ?string $metaKeywords null;
  56.     public function __construct(JournalVolume $parentLanguage $lang)
  57.     {
  58.         $this->setUuid();
  59.         $this->parent $parent;
  60.         $this->lang $lang;
  61.         $this->uniqueKey sprintf('%s_%s'$parent->getParent()->getId(), $lang->value);
  62.         $this->createdAt = new \DateTimeImmutable();
  63.         $this->updatedAt = new \DateTimeImmutable();
  64.         $parent->addTranslation($this);
  65.     }
  66.     public function getTitle(): ?string
  67.     {
  68.         return $this->title;
  69.     }
  70.     public function setTitle(?string $title): self
  71.     {
  72.         $this->title $title;
  73.         return $this;
  74.     }
  75.     public function getFullTitle(): ?string
  76.     {
  77.         /** @var JournalVolume $parent */
  78.         $parent $this->parent;
  79.         return sprintf(
  80.             "%s - %s",
  81.             $parent->getParent()->readTranslation($this->lang'title'),
  82.             $this->title
  83.         );
  84.     }
  85.     public function getSubtitle(): ?string
  86.     {
  87.         return $this->subtitle;
  88.     }
  89.     public function setSubtitle(?string $subtitle): self
  90.     {
  91.         $this->subtitle $subtitle;
  92.         return $this;
  93.     }
  94.     public function getFundingDescription(): ?string
  95.     {
  96.         return $this->fundingDescription;
  97.     }
  98.     public function setFundingDescription(?string $fundingDescription): self
  99.     {
  100.         $this->fundingDescription $fundingDescription;
  101.         return $this;
  102.     }
  103.     public function getMetaTitle(): ?string
  104.     {
  105.         return $this->metaTitle;
  106.     }
  107.     public function setMetaTitle(?string $metaTitle): self
  108.     {
  109.         $this->metaTitle $metaTitle;
  110.         return $this;
  111.     }
  112.     public function getMetaDescription(): ?string
  113.     {
  114.         return $this->metaDescription;
  115.     }
  116.     public function setMetaDescription(?string $metaDescription): self
  117.     {
  118.         $this->metaDescription $metaDescription;
  119.         return $this;
  120.     }
  121.     public function getMetaKeywords(): ?string
  122.     {
  123.         return $this->metaKeywords;
  124.     }
  125.     public function setMetaKeywords(?string $metaKeywords): self
  126.     {
  127.         $this->metaKeywords $metaKeywords;
  128.         return $this;
  129.     }
  130.     public function clone(JournalVolume $parent): self
  131.     {
  132.         $clone = clone $this;
  133.         $clone->id null;
  134.         $clone->setUuid();
  135.         $clone->parent $parent;
  136.         $clone->parent->addTranslation($clone);
  137.         $clone->createdAt = new \DateTimeImmutable();
  138.         $clone->updatedAt = new \DateTimeImmutable();
  139.         return $clone;
  140.     }
  141. }