src/Entity/JournalArticleBibliographyEntry.php line 57

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types,
  5.     Doctrine\Common\Collections\ArrayCollection;
  6. use Symfony\Component\Serializer\Annotation\Groups,
  7.     Symfony\Component\Validator\Constraints as Assert;
  8. use ApiPlatform\Metadata\ApiResource,
  9.     ApiPlatform\Metadata\ApiProperty,
  10.     ApiPlatform\Metadata\Get,
  11.     ApiPlatform\Metadata\GetCollection,
  12.     ApiPlatform\Metadata\Post,
  13.     ApiPlatform\Metadata\Put,
  14.     ApiPlatform\Metadata\Delete,
  15.     ApiPlatform\Metadata\ApiFilter,
  16.     ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  17. use App\Entity\Trait\IdTrait,
  18.     App\Entity\Trait\UuidTrait,
  19.     App\Entity\Trait\OrdTrait,
  20.     App\Entity\Trait\TimestampableTrait,
  21.     App\Entity\Trait\TranslatableTrait,
  22.     App\Entity\Trait\Languages\LanguageableChildTrait,
  23.     App\Entity\Interface\TranslatableInterface,
  24.     App\Entity\Interface\OrderableInterface,
  25.     App\Entity\Interface\LanguageableChildInterface;
  26. use App\Filter\IriFilter,
  27.     App\Repository\JournalArticleBibliographyEntryRepository;
  28. #[ApiResource(
  29.     description'Journal article bibliography entries',
  30.     normalizationContext: ['groups' => [
  31.         'read',
  32.         'read:' self::class,
  33.         'read:' self::class . 'Translation'
  34.     ]],
  35.     denormalizationContext: ['groups' => ['write']],
  36.     security'is_granted("' Journal::class . '")',
  37.     order: ['ord' => 'desc'],
  38.     operations: [
  39.         new GetCollection(),
  40.         new GetCollection(uriTemplate'/journal_article_bibliography_entries_all'paginationEnabledfalse),
  41.         new Post(denormalizationContext: ['groups' => ['write',  'post']]),
  42.         new Get(),
  43.         new Put(),
  44.         new Delete(),
  45.     ],
  46.     extraProperties: ['standard_put' => false],
  47. )]
  48. #[ApiFilter(IriFilter::class, properties: ['parent'])]
  49. #[ApiFilter(OrderFilter::class, properties: ['ord'])]
  50. #[ORM\Entity(repositoryClassJournalArticleBibliographyEntryRepository::class)]
  51. class JournalArticleBibliographyEntry implements TranslatableInterfaceOrderableInterfaceLanguageableChildInterface
  52. {
  53.     use IdTrait,
  54.         UuidTrait,
  55.         OrdTrait,
  56.         TimestampableTrait,
  57.         TranslatableTrait,
  58.         LanguageableChildTrait;
  59.     #[ApiProperty(description'Parent'readableLinkfalsewritableLinkfalse)]
  60.     #[Groups(['read''post'])]
  61.     #[Assert\NotNull]
  62.     #[ORM\ManyToOne(targetEntityJournalArticle::class, inversedBy'bibliographyEntries')]
  63.     #[ORM\JoinColumn(onDelete'cascade'nullablefalse)]
  64.     private JournalArticle $parent;
  65.     #[ApiProperty(description'DOI')]
  66.     #[Groups(['read:' self::class, 'write'])]
  67.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  68.     private ?string $doi null;
  69.     #[ApiProperty(description'Article number')]
  70.     #[Groups(['read:' self::class, 'write'])]
  71.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  72.     private ?string $articleNumber null;
  73.     #[ApiProperty(description'PubMed')]
  74.     #[Groups(['read:' self::class, 'write'])]
  75.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  76.     private ?string $pubMed null;
  77.     #[ApiProperty(description'Doaj')]
  78.     #[Groups(['read:' self::class, 'write'])]
  79.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  80.     private ?string $doaj null;
  81.     #[ApiProperty(description'Google scholar')]
  82.     #[Groups(['read:' self::class, 'write'])]
  83.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  84.     private ?string $googleScholar null;
  85.     #[ApiProperty(description'Is header')]
  86.     #[Groups(['read:' self::class, 'write'])]
  87.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  88.     protected bool $isHeader false;
  89.     public function __construct(JournalArticle $parent)
  90.     {
  91.         $this->setUuid();
  92.         $this->parent $parent;
  93.         $this->translations = new ArrayCollection();
  94.         foreach ($this->getParentLanguages() as $lang) {
  95.             new JournalArticleBibliographyEntryTranslation($this$lang);
  96.         }
  97.         $this->createdAt = new \DateTimeImmutable();
  98.         $this->updatedAt = new \DateTimeImmutable();
  99.         $parent->addBibliographyEntry($this);
  100.     }
  101.     public function getParent(): JournalArticle
  102.     {
  103.         return $this->parent;
  104.     }
  105.     public function getDoi(): ?string
  106.     {
  107.         // https://doi.org/
  108.         return $this->doi;
  109.     }
  110.     public function setDoi(?string $doi): self
  111.     {
  112.         $this->doi $doi;
  113.         return $this;
  114.     }
  115.     public function getArticleNumber(): ?string
  116.     {
  117.         return $this->articleNumber;
  118.     }
  119.     public function setArticleNumber(?string $articleNumber): self
  120.     {
  121.         $this->articleNumber $articleNumber;
  122.         return $this;
  123.     }
  124.     public function getPubMed(): ?string
  125.     {
  126.         // https://pubmed.ncbi.nlm.nih.gov/?term=
  127.         return $this->pubMed;
  128.     }
  129.     public function setPubMed(?string $pubMed): self
  130.     {
  131.         $this->pubMed $pubMed;
  132.         return $this;
  133.     }
  134.     public function getDoaj(): ?string
  135.     {
  136.         // https://doaj.org/article/
  137.         return $this->doaj;
  138.     }
  139.     public function setDoaj(?string $doaj): self
  140.     {
  141.         $this->doaj $doaj;
  142.         return $this;
  143.     }
  144.     public function getGoogleScholar(): ?string
  145.     {
  146.         // https://scholar.google.com/scholar?q=
  147.         return $this->googleScholar;
  148.     }
  149.     public function setGoogleScholar(?string $googleScholar): self
  150.     {
  151.         $this->googleScholar $googleScholar;
  152.         return $this;
  153.     }
  154.     public function setIsHeader(bool $isHeader): self
  155.     {
  156.         $this->isHeader $isHeader;
  157.         return $this;
  158.     }
  159.     public function getIsHeader(): bool
  160.     {
  161.         return $this->isHeader;
  162.     }
  163.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  164.     {
  165.         $this->updatedAt $updatedAt;
  166.         $this->getParent()->setUpdatedAt($updatedAt);
  167.         return $this;
  168.     }
  169. }