src/Entity/NewsTranslation.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\Trait\SlugTrait,
  16.     App\Entity\Interface\TranslationInterface,
  17.     App\Entity\Interface\ThumbableInterface,
  18.     App\Repository\NewsTranslationRepository;
  19. use App\Enum\Language;
  20. #[ApiResource(
  21.     security'is_granted("' News::class . '")',
  22.     operations: [ new Get() ],
  23.     extraProperties: ['standard_put' => false],
  24. )]
  25. #[ORM\Entity(repositoryClassNewsTranslationRepository::class)]
  26. class NewsTranslation implements TranslationInterfaceThumbableInterface
  27. {
  28.     use IdTrait,
  29.         UuidTrait,
  30.         TimestampableTrait,
  31.         TranslationTrait,
  32.         ImageThumbableTrait,
  33.         SlugTrait;
  34.     #[ApiProperty(description'Title')]
  35.     #[Groups(['read''write'])]
  36.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  37.     private ?string $title null;
  38.     #[ApiProperty(description'Subtitle')]
  39.     #[Groups(['read:' self::class, 'write'])]
  40.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  41.     private ?string $subtitle null;
  42.     #[ApiProperty(description'Short lead')]
  43.     #[Groups(['read:' self::class, 'write'])]
  44.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  45.     private ?string $shortLead null;
  46.     #[ApiProperty(description'Alt')]
  47.     #[Groups(['read:' self::class, 'write'])]
  48.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  49.     private ?string $alt null;
  50.     public function __construct(News $parentLanguage $lang)
  51.     {
  52.         $this->setUuid();
  53.         $this->parent $parent;
  54.         $this->lang $lang;
  55.         $this->thumbs = new ArrayCollection();
  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 getSubtitle(): ?string
  70.     {
  71.         return $this->subtitle;
  72.     }
  73.     public function setSubtitle(?string $subtitle): self
  74.     {
  75.         $this->subtitle $subtitle;
  76.         return $this;
  77.     }
  78.     public function getShortLead(): ?string
  79.     {
  80.         return $this->shortLead;
  81.     }
  82.     public function setShortLead(?string $shortLead): self
  83.     {
  84.         $this->shortLead $shortLead;
  85.         return $this;
  86.     }
  87.     public function getAlt(): ?string
  88.     {
  89.         return $this->alt;
  90.     }
  91.     public function setAlt(?string $alt): self
  92.     {
  93.         $this->alt $alt;
  94.         return $this;
  95.     }
  96. }