src/Entity/DefaultLogotypeTranslation.php line 28

  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\Interface\TranslationInterface,
  15.     App\Enum\Language,
  16.     App\Repository\DefaultLogotypeTranslationRepository;
  17. #[ApiResource(
  18.     security'is_granted("' DefaultLogotype::class . '")',
  19.     operations: [ new Get() ],
  20.     extraProperties: ['standard_put' => false],
  21. )]
  22. #[ORM\Entity(repositoryClassDefaultLogotypeTranslationRepository::class)]
  23. class DefaultLogotypeTranslation implements TranslationInterface
  24. {
  25.     use IdTrait,
  26.         UuidTrait,
  27.         TimestampableTrait,
  28.         TranslationTrait,
  29.         ImageTrait;
  30.     #[ApiProperty(description'Title')]
  31.     #[Groups(['read''write'])]
  32.     #[ORM\Column(typeTypes::STRINGlength511nullabletrue)]
  33.     private ?string $title null;
  34.     #[ApiProperty(description'Alt')]
  35.     #[Groups(['read:' self::class, 'write'])]
  36.     #[ORM\Column(typeTypes::STRINGlength1023nullabletrue)]
  37.     private ?string $alt null;
  38.     public function __construct(DefaultLogotype $parentLanguage $lang)
  39.     {
  40.         $this->setUuid();
  41.         $this->parent $parent;
  42.         $this->lang $lang;
  43.         $this->createdAt = new \DateTimeImmutable();
  44.         $this->updatedAt = new \DateTimeImmutable();
  45.         $parent->addTranslation($this);
  46.     }
  47.     public function getTitle(): ?string
  48.     {
  49.         return $this->title;
  50.     }
  51.     public function setTitle(?string $title): self
  52.     {
  53.         $this->title $title;
  54.         /** @var DefaultLogotype */
  55.         $parent $this->parent;
  56.         if ($this->lang === $parent->getNativeLanguage()) {
  57.             $parent->setNativeTitle($title);
  58.         }
  59.         return $this;
  60.     }
  61.     public function getAlt(): ?string
  62.     {
  63.         return $this->alt;
  64.     }
  65.     public function setAlt(?string $alt): self
  66.     {
  67.         $this->alt $alt;
  68.         return $this;
  69.     }
  70. }