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'PubMed Central')]
  78.     #[Groups(['read:' self::class, 'write'])]
  79.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  80.     private ?string $pubMedCentral 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.         return $this->doi;
  108.     }
  109.     public function setDoi(?string $doi): self
  110.     {
  111.         $this->doi $doi;
  112.         return $this;
  113.     }
  114.     public function getArticleNumber(): ?string
  115.     {
  116.         return $this->articleNumber;
  117.     }
  118.     public function setArticleNumber(?string $articleNumber): self
  119.     {
  120.         $this->articleNumber $articleNumber;
  121.         return $this;
  122.     }
  123.     public function getPubMed(): ?string
  124.     {
  125.         //https://pubmed.ncbi.nlm.nih.gov/?term=
  126.         return $this->pubMed;
  127.     }
  128.     public function setPubMed(?string $pubMed): self
  129.     {
  130.         $this->pubMed $pubMed;
  131.         return $this;
  132.     }
  133.     public function getPubMedCentral(): ?string
  134.     {
  135.         //https://www.ncbi.nlm.nih.gov/pmc/?term=
  136.         return $this->pubMedCentral;
  137.     }
  138.     public function setPubMedCentral(?string $pubMedCentral): self
  139.     {
  140.         $this->pubMedCentral $pubMedCentral;
  141.         return $this;
  142.     }
  143.     public function getGoogleScholar(): ?string
  144.     {
  145.         //https://scholar.google.com/scholar?q=
  146.         return $this->googleScholar;
  147.     }
  148.     public function setGoogleScholar(?string $googleScholar): self
  149.     {
  150.         $this->googleScholar $googleScholar;
  151.         return $this;
  152.     }
  153.     public function setIsHeader(bool $isHeader): self
  154.     {
  155.         $this->isHeader $isHeader;
  156.         return $this;
  157.     }
  158.     public function getIsHeader(): bool
  159.     {
  160.         return $this->isHeader;
  161.     }
  162. }