src/Entity/PartnerTranslation.php line 30

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use ApiPlatform\Metadata\ApiProperty,
  7.     ApiPlatform\Metadata\ApiResource,
  8.     ApiPlatform\Metadata\Get;
  9. use App\Entity\Trait\IdTrait,
  10.     App\Entity\Trait\UuidTrait,
  11.     App\Entity\Trait\TimestampableTrait,
  12.     App\Entity\Trait\TranslationTrait,
  13.     App\Entity\Trait\Media\ImageTrait,
  14.     App\Entity\Trait\SlugTrait,
  15.     App\Entity\Interface\TranslationInterface,
  16.     App\Enum\Language,
  17.     App\Attribute\Sanitizeable,
  18.     App\Repository\PartnerTranslationRepository;
  19. #[ApiResource(
  20.     security'is_granted("' Partner::class . '")',
  21.     operations: [ new Get() ],
  22.     extraProperties: ['standard_put' => false],
  23. )]
  24. #[ORM\Entity(repositoryClassPartnerTranslationRepository::class)]
  25. class PartnerTranslation implements TranslationInterface
  26. {
  27.     use IdTrait,
  28.         UuidTrait,
  29.         TimestampableTrait,
  30.         TranslationTrait,
  31.         ImageTrait,
  32.         SlugTrait;
  33.     #[ApiProperty(description'Title')]
  34.     #[Groups(['read''write'])]
  35.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  36.     private ?string $title null;
  37.     #[ApiProperty(description'Alt')]
  38.     #[Groups(['read:' self::class, 'write'])]
  39.     #[ORM\Column(typeTypes::STRINGlength1023nullabletrue)]
  40.     private ?string $alt null;
  41.     #[ApiProperty(description'Description')]
  42.     #[Groups(['read:' self::class, 'write'])]
  43.     #[Sanitizeable]
  44.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  45.     private ?string $description null;
  46.     public function __construct(Partner $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.         /** @var Partner */
  63.         $parent $this->parent;
  64.         if ($this->lang === $parent->getNativeLanguage()) {
  65.             $parent->setNativeTitle($title);
  66.         }
  67.         return $this;
  68.     }
  69.     public function getAlt(): ?string
  70.     {
  71.         return $this->alt;
  72.     }
  73.     public function setAlt(?string $alt): self
  74.     {
  75.         $this->alt $alt;
  76.         return $this;
  77.     }
  78.     public function getDescription(): ?string
  79.     {
  80.         return $this->description;
  81.     }
  82.     public function setDescription(?string $description): self
  83.     {
  84.         $this->description $description;
  85.         return $this;
  86.     }
  87. }