src/Entity/JournalTranslation.php line 33

  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\Interface\TranslationInterface,
  10.     App\Entity\Trait\IdTrait,
  11.     App\Entity\Trait\UuidTrait,
  12.     App\Entity\Trait\TimestampableTrait,
  13.     App\Entity\Trait\TranslationTrait,
  14.     App\Entity\Trait\SEOTrait,
  15.     App\Entity\Trait\Media\SetMediaTrait;
  16. use App\Enum\Language,
  17.     App\Entity\Media,
  18.     App\Repository\JournalTranslationRepository;
  19. use App\Validator\Constraints as CustomAssert;
  20. #[ApiResource(
  21.     security'is_granted("' Journal::class . '")',
  22.     operations: [ new Get() ],
  23.     extraProperties: ['standard_put' => false],
  24. )]
  25. #[ORM\Entity(repositoryClassJournalTranslationRepository::class)]
  26. class JournalTranslation implements TranslationInterface
  27. {
  28.     use IdTrait,
  29.         UuidTrait,
  30.         TimestampableTrait,
  31.         TranslationTrait,
  32.         SEOTrait,
  33.         SetMediaTrait;
  34.     #[ApiProperty(description'Title')]
  35.     #[Groups(['read''write'])]
  36.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  37.     private ?string $title null;
  38.     #[ApiProperty(description'Title sort key')]
  39.     #[Groups(['read:' self::class])]
  40.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  41.     private ?string $titleSortKey null;
  42.     #[ApiProperty(description'Subtitle')]
  43.     #[Groups(['read:' self::class, 'write'])]
  44.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  45.     private ?string $subtitle null;
  46.     #[ApiProperty(description'Cover'writableLinkfalse)]
  47.     #[Groups(['read:' self::class, 'write'])]
  48.     #[CustomAssert\ValidMediaMimeType(types: ['image/*'])]
  49.     #[ORM\ManyToOne(targetEntityMedia::class, cascade: ['persist''remove'])]
  50.     #[ORM\JoinColumn(onDelete'set null')]
  51.     private ?Media $cover null;
  52.     #[ApiProperty(description'Cover photo alt text')]
  53.     #[Groups(['read:' self::class, 'write'])]
  54.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  55.     private ?string $coverAlt null;
  56.     #[ApiProperty(description'Page header title')]
  57.     #[Groups(['read:' self::class, 'write'])]
  58.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  59.     private ?string $pageHeaderTitle null;
  60.     #[ApiProperty(description'Alert A: message')]
  61.     #[Groups(['read:' self::class, 'write'])]
  62.     #[ORM\Column(typeTypes::STRINGlength1023nullabletrue)]
  63.     private ?string $alertAMessage null;
  64.     #[ApiProperty(description'Alert A: link')]
  65.     #[Groups(['read:' self::class, 'write'])]
  66.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  67.     private ?string $alertALink null;
  68.     #[ApiProperty(description'Alert B: message')]
  69.     #[Groups(['read:' self::class, 'write'])]
  70.     #[ORM\Column(typeTypes::STRINGlength1023nullabletrue)]
  71.     private ?string $alertBMessage null;
  72.     #[ApiProperty(description'Alert B: link')]
  73.     #[Groups(['read:' self::class, 'write'])]
  74.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  75.     private ?string $alertBLink null;
  76.     #[ApiProperty(description'Logo'writableLinkfalse)]
  77.     #[Groups(['read:' self::class, 'write'])]
  78.     #[CustomAssert\ValidMediaMimeType(types: ['image/*'])]
  79.     #[ORM\ManyToOne(targetEntityMedia::class, cascade: ['persist''remove'])]
  80.     #[ORM\JoinColumn(onDelete'set null')]
  81.     private ?Media $logo null;
  82.     #[ApiProperty(description'Logo photo alt text')]
  83.     #[Groups(['read:' self::class, 'write'])]
  84.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  85.     private ?string $logoAlt null;
  86.     #[ApiProperty(description'Affiliation logo'writableLinkfalse)]
  87.     #[Groups(['read:' self::class, 'write'])]
  88.     #[ORM\ManyToOne(targetEntityMedia::class, cascade: ['persist''remove'])]
  89.     #[ORM\JoinColumn(onDelete'set null')]
  90.     private ?Media $affiliationLogo null;
  91.     #[ApiProperty(description'Affiliation logo photo alt text')]
  92.     #[Groups(['read:' self::class, 'write'])]
  93.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  94.     private ?string $affiliationLogoAlt null;
  95.     #[ApiProperty(description'Affiliation text')]
  96.     #[Groups(['read:' self::class, 'write'])]
  97.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  98.     private ?string $affiliationText null;
  99.     #[ApiProperty(description'Footer column A title')]
  100.     #[Groups(['read:' self::class, 'write'])]
  101.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  102.     private ?string $footerColumnATitle null;
  103.     #[ApiProperty(description'Footer column A text')]
  104.     #[Groups(['read:' self::class, 'write'])]
  105.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  106.     private ?string $footerColumnAText null;
  107.     #[ApiProperty(description'Footer column B title')]
  108.     #[Groups(['read:' self::class, 'write'])]
  109.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  110.     private ?string $footerColumnBTitle null;
  111.     #[ApiProperty(description'Footer column B text')]
  112.     #[Groups(['read:' self::class, 'write'])]
  113.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  114.     private ?string $footerColumnBText null;
  115.     #[ApiProperty(description'Footer column C title')]
  116.     #[Groups(['read:' self::class, 'write'])]
  117.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  118.     private ?string $footerColumnCTitle null;
  119.     #[ApiProperty(description'Footer column C text')]
  120.     #[Groups(['read:' self::class, 'write'])]
  121.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  122.     private ?string $footerColumnCText null;
  123.     #[ApiProperty(description'Footer column D title')]
  124.     #[Groups(['read:' self::class, 'write'])]
  125.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  126.     private ?string $footerColumnDTitle null;
  127.     #[ApiProperty(description'Footer column D text')]
  128.     #[Groups(['read:' self::class, 'write'])]
  129.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  130.     private ?string $footerColumnDText null;
  131.     #[ApiProperty(description'Additional section info')]
  132.     #[Groups(['read:' self::class, 'write'])]
  133.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  134.     private ?string $additionalSectionInfo null;
  135.     public function __construct(Journal $parentLanguage $lang)
  136.     {
  137.         $this->setUuid();
  138.         $this->parent $parent;
  139.         $this->lang $lang;
  140.         $this->createdAt = new \DateTimeImmutable();
  141.         $this->updatedAt = new \DateTimeImmutable();
  142.         $parent->addTranslation($this);
  143.     }
  144.     public function getTitle(): ?string
  145.     {
  146.         return $this->title;
  147.     }
  148.     public function setTitle(?string $title): self
  149.     {
  150.         $this->title $title;
  151.         $collator = new \Collator($this->lang->value);
  152.         $this->titleSortKey bin2hex($collator->getSortKey($title));
  153.         /** @var Journal */
  154.         $parent $this->parent;
  155.         if ($this->lang === $parent->getNativeLanguage()) {
  156.             $parent
  157.                 ->setNativeTitle($title)
  158.                 ->setNativeTitleSortKey($this->titleSortKey);
  159.         }
  160.         return $this;
  161.     }
  162.     public function getTitleSortKey(): ?string
  163.     {
  164.         return $this->titleSortKey;
  165.     }
  166.     public function getSubtitle(): ?string
  167.     {
  168.         return $this->subtitle;
  169.     }
  170.     public function setSubtitle(?string $subtitle): self
  171.     {
  172.         $this->subtitle $subtitle;
  173.         return $this;
  174.     }
  175.     public function getCover(): ?Media
  176.     {
  177.         return $this->cover;
  178.     }
  179.     public function setCover(?Media $cover): self
  180.     {
  181.         return $this->setMedia('cover'$cover);
  182.     }
  183.     public function getCoverAlt(): ?string
  184.     {
  185.         return $this->coverAlt;
  186.     }
  187.     public function setCoverAlt(?string $coverAlt): self
  188.     {
  189.         $this->coverAlt $coverAlt;
  190.         return $this;
  191.     }
  192.     public function getPageHeaderTitle(): ?string
  193.     {
  194.         return $this->pageHeaderTitle;
  195.     }
  196.     public function setPageHeaderTitle(?string $pageHeaderTitle): self
  197.     {
  198.         $this->pageHeaderTitle $pageHeaderTitle;
  199.         return $this;
  200.     }
  201.     public function getAlertAMessage(): ?string
  202.     {
  203.         return $this->alertAMessage;
  204.     }
  205.     public function setAlertAMessage(?string $alertAMessage): self
  206.     {
  207.         $this->alertAMessage $alertAMessage;
  208.         return $this;
  209.     }
  210.     public function getAlertALink(): ?string
  211.     {
  212.         return $this->alertALink;
  213.     }
  214.     public function setAlertALink(?string $alertALink): self
  215.     {
  216.         $this->alertALink $alertALink;
  217.         return $this;
  218.     }
  219.     public function getAlertBMessage(): ?string
  220.     {
  221.         return $this->alertBMessage;
  222.     }
  223.     public function setAlertBMessage(?string $alertBMessage): self
  224.     {
  225.         $this->alertBMessage $alertBMessage;
  226.         return $this;
  227.     }
  228.     public function getAlertBLink(): ?string
  229.     {
  230.         return $this->alertBLink;
  231.     }
  232.     public function setAlertBLink(?string $alertBLink): self
  233.     {
  234.         $this->alertBLink $alertBLink;
  235.         return $this;
  236.     }
  237.     public function getLogo(): ?Media
  238.     {
  239.         return $this->logo;
  240.     }
  241.     public function setLogo(?Media $logo): self
  242.     {
  243.         return $this->setMedia('logo'$logo);
  244.     }
  245.     public function getLogoAlt(): ?string
  246.     {
  247.         return $this->logoAlt;
  248.     }
  249.     public function setLogoAlt(?string $logoAlt): self
  250.     {
  251.         $this->logoAlt $logoAlt;
  252.         return $this;
  253.     }
  254.     public function getAffiliationLogo(): ?Media
  255.     {
  256.         return $this->affiliationLogo;
  257.     }
  258.     public function setAffiliationLogo(?Media $affiliationLogo): self
  259.     {
  260.         return $this->setMedia('affiliationLogo'$affiliationLogo);
  261.         return $this;
  262.     }
  263.     public function getAffiliationLogoAlt(): ?string
  264.     {
  265.         return $this->affiliationLogoAlt;
  266.     }
  267.     public function setAffiliationLogoAlt(?string $affiliationLogoAlt): self
  268.     {
  269.         $this->affiliationLogoAlt $affiliationLogoAlt;
  270.         return $this;
  271.     }
  272.     public function getAffiliationText(): ?string
  273.     {
  274.         return $this->affiliationText;
  275.     }
  276.     public function setAffiliationText(?string $affiliationText): self
  277.     {
  278.         $this->affiliationText $affiliationText;
  279.         return $this;
  280.     }
  281.     public function getFooterColumnATitle(): ?string
  282.     {
  283.         return $this->footerColumnATitle;
  284.     }
  285.     public function setFooterColumnATitle(?string $footerColumnATitle): self
  286.     {
  287.         $this->footerColumnATitle $footerColumnATitle;
  288.         return $this;
  289.     }
  290.     public function getFooterColumnAText(): ?string
  291.     {
  292.         return $this->footerColumnAText;
  293.     }
  294.     public function setFooterColumnAText(?string $footerColumnAText): self
  295.     {
  296.         $this->footerColumnAText $footerColumnAText;
  297.         return $this;
  298.     }
  299.     public function getFooterColumnBTitle(): ?string
  300.     {
  301.         return $this->footerColumnBTitle;
  302.     }
  303.     public function setFooterColumnBTitle(?string $footerColumnBTitle): self
  304.     {
  305.         $this->footerColumnBTitle $footerColumnBTitle;
  306.         return $this;
  307.     }
  308.     public function getFooterColumnBText(): ?string
  309.     {
  310.         return $this->footerColumnBText;
  311.     }
  312.     public function setFooterColumnBText(?string $footerColumnBText): self
  313.     {
  314.         $this->footerColumnBText $footerColumnBText;
  315.         return $this;
  316.     }
  317.     public function getFooterColumnCTitle(): ?string
  318.     {
  319.         return $this->footerColumnCTitle;
  320.     }
  321.     public function setFooterColumnCTitle(?string $footerColumnCTitle): self
  322.     {
  323.         $this->footerColumnCTitle $footerColumnCTitle;
  324.         return $this;
  325.     }
  326.     public function getFooterColumnCText(): ?string
  327.     {
  328.         return $this->footerColumnCText;
  329.     }
  330.     public function setFooterColumnCText(?string $footerColumnCText): self
  331.     {
  332.         $this->footerColumnCText $footerColumnCText;
  333.         return $this;
  334.     }
  335.     public function getFooterColumnDTitle(): ?string
  336.     {
  337.         return $this->footerColumnDTitle;
  338.     }
  339.     public function setFooterColumnDTitle(?string $footerColumnDTitle): self
  340.     {
  341.         $this->footerColumnDTitle $footerColumnDTitle;
  342.         return $this;
  343.     }
  344.     public function getFooterColumnDText(): ?string
  345.     {
  346.         return $this->footerColumnDText;
  347.     }
  348.     public function setFooterColumnDText(?string $footerColumnDText): self
  349.     {
  350.         $this->footerColumnDText $footerColumnDText;
  351.         return $this;
  352.     }
  353.     public function getAdditionalSectionInfo(): ?string
  354.     {
  355.         return $this->additionalSectionInfo;
  356.     }
  357.     public function setAdditionalSectionInfo(?string $additionalSectionInfo): self
  358.     {
  359.         $this->additionalSectionInfo $additionalSectionInfo;
  360.         return $this;
  361.     }
  362.     public function clone(Journal $parent): self
  363.     {
  364.         $clone = clone $this;
  365.         $clone->id null;
  366.         $clone->setUuid();
  367.         if ($clone->cover) {
  368.             $clone->cover $this->cover->clone();
  369.             $clone->cover->setRelated(self::class . ':' $clone->uuid->toString());
  370.         }
  371.         if ($clone->logo) {
  372.             $clone->logo $this->logo->clone();
  373.             $clone->logo->setRelated(self::class . ':' $clone->uuid->toString());
  374.         }
  375.         if ($clone->affiliationLogo) {
  376.             $clone->affiliationLogo $this->logo->clone();
  377.             $clone->affiliationLogo->setRelated(self::class . ':' $clone->uuid->toString());
  378.         }
  379.         $clone->parent $parent;
  380.         $clone->parent->addTranslation($clone);
  381.         $clone->createdAt = new \DateTimeImmutable();
  382.         $clone->updatedAt = new \DateTimeImmutable();
  383.         return $clone;
  384.     }
  385. }