src/Entity/JournalArticleTranslation.php line 35

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types,
  5.     Doctrine\Common\Collections\Collection,
  6.     Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping\Index;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use ApiPlatform\Metadata\ApiProperty,
  10.     ApiPlatform\Metadata\ApiResource,
  11.     ApiPlatform\Metadata\Get;
  12. use App\Entity\Interface\TranslationInterface,
  13.     App\Entity\Trait\IdTrait,
  14.     App\Entity\Trait\UuidTrait,
  15.     App\Entity\Trait\TimestampableTrait,
  16.     App\Entity\Trait\TranslationTrait,
  17.     App\Entity\Trait\SlugTrait;
  18. use App\Enum\Language,
  19.     App\Attribute\Sanitizeable,
  20.     App\Attribute\DenormalizationPriority,
  21.     App\Repository\JournalArticleTranslationRepository;
  22. #[ApiResource(
  23.     security'is_granted("' Journal::class . '")',
  24.     operations: [ new Get() ],
  25.     extraProperties: ['standard_put' => false],
  26. )]
  27. #[Index(fields: ["lang"], name"lang_idx")]
  28. #[ORM\Entity(repositoryClassJournalArticleTranslationRepository::class)]
  29. class JournalArticleTranslation implements TranslationInterface
  30. {
  31.     use IdTrait,
  32.         UuidTrait,
  33.         TimestampableTrait,
  34.         TranslationTrait,
  35.         SlugTrait;
  36.     /**
  37.      * @deprecated
  38.      * @see \App\Entity\JournalArticleMetadataTranslation
  39.      */
  40.     #[ApiProperty(description'Title')]
  41.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  42.     private ?string $title null;
  43.     #[ApiProperty(description'Copyrights')]
  44.     #[Groups(['read:' self::class, 'write'])]
  45.     #[Sanitizeable]
  46.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  47.     private ?string $copyrights null;
  48.     #[ApiProperty(description'Funding description')]
  49.     #[Groups(['read:' self::class, 'write'])]
  50.     #[Sanitizeable]
  51.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  52.     private ?string $fundingDescription null;
  53.     #[ApiProperty(description'Conflict of interest')]
  54.     #[Groups(['read:' self::class, 'write'])]
  55.     #[Sanitizeable]
  56.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  57.     private ?string $conflictOfInterest null;
  58.     #[ApiProperty(description'Info about author')]
  59.     #[Groups(['read:' self::class, 'write'])]
  60.     #[Sanitizeable]
  61.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  62.     private ?string $infoAboutAuthor null;
  63.     #[ApiProperty(description'Author corrections')]
  64.     #[Groups(['read:' self::class, 'write'])]
  65.     #[Sanitizeable]
  66.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  67.     private ?string $authorCorrections null;
  68.     #[ApiProperty(description'Meta title')]
  69.     #[Groups(['read:' self::class, 'write'])]
  70.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  71.     private ?string $metaTitle null;
  72.     #[ApiProperty(description'Meta description')]
  73.     #[Groups(['read:' self::class, 'write'])]
  74.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  75.     private ?string $metaDescription null;
  76.     #[ApiProperty(description'Meta keywords')]
  77.     #[Groups(['read:' self::class, 'write'])]
  78.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  79.     private ?string $metaKeywords null;
  80.     /**
  81.      * @deprecated
  82.      * @see \App\Entity\JournalArticleMetadataTranslation
  83.      */
  84.     #[ApiProperty(description'Abstract')]
  85.     #[Sanitizeable]
  86.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  87.     private ?string $abstract null;
  88.     #[ApiProperty(description'Bibliography')]
  89.     #[Groups(['read:' self::class, 'write'])]
  90.     #[Sanitizeable]
  91.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  92.     private ?string $bibliography null;
  93.     #[ApiProperty(description'Old imported bibliography')]
  94.     #[Groups(['read:' self::class, 'write'])]
  95.     #[Sanitizeable]
  96.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  97.     private ?string $oldImportedBibliography null;
  98.     /**
  99.      * @deprecated
  100.      * @see \App\Entity\JournalArticleMetadataTranslation
  101.      */
  102.     #[ApiProperty(description'Is keywords import reseting previous')]
  103.     #[DenormalizationPriority(DenormalizationPriority::TOP)]
  104.     private bool $isKeywordsImportResetingPrevious false;
  105.     #[ApiProperty(description'Imported bibliography')]
  106.     #[Groups(['write'])]
  107.     private ?string $importedBibliography null;
  108.     /**
  109.      * @deprecated
  110.      * @see \App\Entity\JournalArticleMetadataTranslation
  111.      */
  112.     #[ApiProperty(description'Keywords')]
  113.     #[ORM\OneToMany(
  114.         targetEntityJournalArticleTranslationKeyword::class,
  115.         mappedBy'parent',
  116.         cascade: ['persist''remove'],
  117.         orphanRemovaltrue
  118.     )]
  119.     #[ORM\OrderBy(['ord' => 'desc'])]
  120.     private Collection $keywords;
  121.     public function __construct(JournalArticle $parentLanguage $lang)
  122.     {
  123.         $this->setUuid();
  124.         $this->parent $parent;
  125.         $this->lang $lang;
  126.         $this->copyrights $parent
  127.             ->getIssue()
  128.             ->getTranslation($lang)
  129.             ?->getCopyrights();
  130.         $this->keywords = new ArrayCollection();
  131.         $this->createdAt = new \DateTimeImmutable();
  132.         $this->updatedAt = new \DateTimeImmutable();
  133.         $parent->addTranslation($this);
  134.     }
  135.     /**
  136.      * @deprecated
  137.      * @see \App\Entity\JournalArticleMetadataTranslation
  138.      */
  139.     public function getTitle(): ?string
  140.     {
  141.         return $this->title;
  142.     }
  143.     /**
  144.      * @deprecated
  145.      * @see \App\Entity\JournalArticleMetadataTranslation
  146.      */
  147.     public function setTitle(?string $title): self
  148.     {
  149.         $this->title $title;
  150.         return $this;
  151.     }
  152.     public function getCopyrights(): ?string
  153.     {
  154.         return $this->copyrights;
  155.     }
  156.     public function setCopyrights(?string $copyrights): self
  157.     {
  158.         $this->copyrights $copyrights;
  159.         return $this;
  160.     }
  161.     public function getFundingDescription(): ?string
  162.     {
  163.         return $this->fundingDescription;
  164.     }
  165.     public function setFundingDescription(?string $fundingDescription): self
  166.     {
  167.         $this->fundingDescription $fundingDescription;
  168.         return $this;
  169.     }
  170.     public function getConflictOfInterest(): ?string
  171.     {
  172.         return $this->conflictOfInterest;
  173.     }
  174.     public function setConflictOfInterest(?string $conflictOfInterest): self
  175.     {
  176.         $this->conflictOfInterest $conflictOfInterest;
  177.         return $this;
  178.     }
  179.     public function getInfoAboutAuthor(): ?string
  180.     {
  181.         return $this->infoAboutAuthor;
  182.     }
  183.     public function setInfoAboutAuthor(?string $infoAboutAuthor): self
  184.     {
  185.         $this->infoAboutAuthor $infoAboutAuthor;
  186.         return $this;
  187.     }
  188.     public function getAuthorCorrections(): ?string
  189.     {
  190.         return $this->authorCorrections;
  191.     }
  192.     public function setAuthorCorrections(?string $authorCorrections): self
  193.     {
  194.         $this->authorCorrections $authorCorrections;
  195.         return $this;
  196.     }
  197.     public function getMetaTitle(): ?string
  198.     {
  199.         return $this->metaTitle;
  200.     }
  201.     public function setMetaTitle(?string $metaTitle): self
  202.     {
  203.         $this->metaTitle $metaTitle;
  204.         return $this;
  205.     }
  206.     public function getMetaDescription(): ?string
  207.     {
  208.         return $this->metaDescription;
  209.     }
  210.     public function setMetaDescription(?string $metaDescription): self
  211.     {
  212.         $this->metaDescription $metaDescription;
  213.         return $this;
  214.     }
  215.     public function getMetaKeywords(): ?string
  216.     {
  217.         return $this->metaKeywords;
  218.     }
  219.     public function setMetaKeywords(?string $metaKeywords): self
  220.     {
  221.         $this->metaKeywords $metaKeywords;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @deprecated
  226.      * @see \App\Entity\JournalArticleMetadataTranslation
  227.      */
  228.     public function getAbstract(): ?string
  229.     {
  230.         return $this->abstract;
  231.     }
  232.     /**
  233.      * @deprecated
  234.      * @see \App\Entity\JournalArticleMetadataTranslation
  235.      */
  236.     public function setAbstract(?string $abstract): self
  237.     {
  238.         $this->abstract $abstract;
  239.         return $this;
  240.     }
  241.     public function getImportedBibliography(): ?string
  242.     {
  243.         return $this->importedBibliography;
  244.     }
  245.     public function setImportedBibliography(?string $importedBibliography): self
  246.     {
  247.         $this->importedBibliography $importedBibliography;
  248.         return $this;
  249.     }
  250.     /**
  251.      * @deprecated
  252.      * @see \App\Entity\JournalArticleMetadataTranslation
  253.      *
  254.      * @return Collection|JournalArticleTranslationKeyword[]
  255.      */
  256.     public function getKeywords(): Collection
  257.     {
  258.         return $this->keywords;
  259.     }
  260.     /**
  261.      * @deprecated
  262.      * @see \App\Entity\JournalArticleMetadataTranslation
  263.      */
  264.     public function addKeyword(JournalArticleTranslationKeyword $keyword): self
  265.     {
  266.         if ($this->keywords->contains($keyword)) {
  267.             return $this;
  268.         }
  269.         $this->keywords[] = $keyword;
  270.         return $this;
  271.     }
  272.     /**
  273.      * @deprecated
  274.      * @see \App\Entity\JournalArticleMetadataTranslation
  275.      */
  276.     public function removeKeyword(JournalArticleTranslationKeyword $keyword): self
  277.     {
  278.         $this->keywords->removeElement($keyword);
  279.         return $this;
  280.     }
  281.     /**
  282.      * @deprecated
  283.      * @see \App\Entity\JournalArticleMetadataTranslation
  284.      */
  285.     public function resetKeywords(): self
  286.     {
  287.         $this->keywords = new ArrayCollection();
  288.         return $this;
  289.     }
  290.     public function getBibliography(): ?string
  291.     {
  292.         return $this->bibliography;
  293.     }
  294.     public function setBibliography(?string $bibliography): self
  295.     {
  296.         $this->bibliography $bibliography;
  297.         return $this;
  298.     }
  299.     public function getOldImportedBibliography(): ?string
  300.     {
  301.         return $this->oldImportedBibliography;
  302.     }
  303.     public function setOldImportedBibliography(?string $oldImportedBibliography): self
  304.     {
  305.         $this->oldImportedBibliography $oldImportedBibliography;
  306.         return $this;
  307.     }
  308.     public function clone(JournalArticle $parent): self
  309.     {
  310.         $clone = clone $this;
  311.         $clone->id null;
  312.         $clone->setUuid();
  313.         $clone->parent $parent;
  314.         $clone->parent->addTranslation($clone);
  315.         $clone->resetKeywords();
  316.         $clone->createdAt = new \DateTimeImmutable();
  317.         $clone->updatedAt = new \DateTimeImmutable();
  318.         return $clone;
  319.     }
  320. }