src/Entity/ContactSubjectTranslation.php line 27

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