src/Entity/JournalSlideTranslation.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types,
  5.     Doctrine\Common\Collections\ArrayCollection;
  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\Media\ImageThumbableTrait,
  15.     App\Entity\Interface\TranslationInterface,
  16.     App\Entity\Interface\ThumbableInterface;
  17. use App\Enum\Language,
  18.     App\Util\ClassUtils,
  19.     App\Repository\JournalSlideTranslationRepository;
  20. #[ApiResource(
  21.     security'is_granted("' Journal::class . '")',
  22.     operations: [ new Get() ],
  23.     extraProperties: ['standard_put' => false],
  24. )]
  25. #[ORM\Entity(repositoryClassJournalSlideTranslationRepository::class)]
  26. class JournalSlideTranslation implements TranslationInterfaceThumbableInterface
  27. {
  28.     use IdTrait,
  29.         UuidTrait,
  30.         TimestampableTrait,
  31.         TranslationTrait,
  32.         ImageThumbableTrait;
  33.     #[ApiProperty(description'Title')]
  34.     #[Groups(['read''write'])]
  35.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  36.     private ?string $title null;
  37.     #[ApiProperty(description'Text')]
  38.     #[Groups(['read:' self::class, 'write'])]
  39.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  40.     private ?string $text null;
  41.     #[ApiProperty(description'CTA')]
  42.     #[Groups(['read:' self::class, 'write'])]
  43.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  44.     private ?string $cta null;
  45.     #[ApiProperty(description'Alt')]
  46.     #[Groups(['read:' self::class, 'write'])]
  47.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  48.     private ?string $alt null;
  49.     #[ApiProperty(description'Link')]
  50.     #[Groups(['read:' self::class, 'write'])]
  51.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  52.     private ?string $link null;
  53.     public function __construct(JournalSlide $parentLanguage $lang)
  54.     {
  55.         $this->setUuid();
  56.         $this->parent $parent;
  57.         $this->lang $lang;
  58.         $this->thumbs = new ArrayCollection();
  59.         $this->createdAt = new \DateTimeImmutable();
  60.         $this->updatedAt = new \DateTimeImmutable();
  61.         $parent->addTranslation($this);
  62.     }
  63.     public function getTitle(): ?string
  64.     {
  65.         return $this->title;
  66.     }
  67.     public function setTitle(?string $title): self
  68.     {
  69.         $this->title $title;
  70.         return $this;
  71.     }
  72.     public function getText(): ?string
  73.     {
  74.         return $this->text;
  75.     }
  76.     public function setText(?string $text): self
  77.     {
  78.         $this->text $text;
  79.         return $this;
  80.     }
  81.     public function getCta(): ?string
  82.     {
  83.         return $this->cta;
  84.     }
  85.     public function setCta(?string $cta): self
  86.     {
  87.         $this->cta $cta;
  88.         return $this;
  89.     }
  90.     public function getAlt(): ?string
  91.     {
  92.         return $this->alt;
  93.     }
  94.     public function setAlt(?string $alt): self
  95.     {
  96.         $this->alt $alt;
  97.         return $this;
  98.     }
  99.     public function getLink(): ?string
  100.     {
  101.         return $this->link;
  102.     }
  103.     public function setLink(?string $link): self
  104.     {
  105.         $this->link $link;
  106.         return $this;
  107.     }
  108.     public function clone(JournalSlide $parent): self
  109.     {
  110.         $clone = clone $this;
  111.         $clone->id null;
  112.         $clone->setUuid();
  113.         if ($clone->media) {
  114.             $clone->media $this->media->clone();
  115.             $clone->media->setRelated(self::class . ':' $clone->uuid->toString());
  116.         }
  117.         $clone->parent $parent;
  118.         $clone->parent->addTranslation($clone);
  119.         ClassUtils::cloneCollection($this$clone'thumbs');
  120.         $clone->createdAt = new \DateTimeImmutable();
  121.         $clone->updatedAt = new \DateTimeImmutable();
  122.         return $clone;
  123.     }
  124. }