src/Entity/Journal.php line 146
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\Common\Collections\Collection,
Doctrine\Common\Collections\ArrayCollection,
Doctrine\DBAL\Types\Types,
Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping\Index;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups,
Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\GetCollection,
ApiPlatform\Metadata\Post,
ApiPlatform\Metadata\Put,
ApiPlatform\Metadata\Delete,
ApiPlatform\Metadata\ApiFilter,
ApiPlatform\Doctrine\Orm\Filter\SearchFilter,
ApiPlatform\Doctrine\Orm\Filter\RangeFilter,
ApiPlatform\Doctrine\Orm\Filter\DateFilter,
ApiPlatform\Doctrine\Orm\Filter\BooleanFilter,
ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\OrdStatTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslatableTrait,
App\Entity\Trait\Languages\JournalLanguagesTrait,
App\Entity\Trait\ArchivedTrait,
App\Entity\Trait\OwnerTrait,
App\Entity\Trait\EditorialGroupableTrait,
App\Entity\Trait\ImportIdTrait,
App\Entity\Interface\TranslatableInterface,
App\Entity\Interface\OrdStatableInterface,
App\Entity\Interface\LanguageableInterface,
App\Entity\Interface\EditorialGroupableInterface,
App\Entity\Interface\ArchivableInterface,
App\Entity\Interface\OwnerableInterface,
App\Entity\Interface\CloneableInterface,
App\Repository\JournalRepository;
use App\Enum\Language,
App\Enum\JournalCoverType,
App\Enum\JournalDefaultPage,
App\Entity\Admin,
App\Security\Voter\ArchivableVoter,
App\Lib\Actions,
App\DTO\CloneDTO,
App\StateProcessor\CloneProcessor,
App\Security\Voter\CloneVoter;
use App\Attribute\DenormalizationInject,
App\Util\ClassUtils,
App\Filter\IriFilter;
use App\Controller\Export\Journal\JournalCrossrefExporter,
App\Controller\Export\Journal\JournalSimcheckCrossrefExporter,
App\Controller\Export\Journal\JournalLicenceFulltextCrossrefExporter;
#[ApiResource(
description: 'Journals',
normalizationContext: ['groups' => [
'read',
'read:' . self::class,
'read:' . self::class . 'Translation'
]],
denormalizationContext: ['groups' => ['write']],
security: 'is_granted("' . self::class . '")',
order: ['ord' => 'desc'],
operations: [
new GetCollection(),
new GetCollection(
uriTemplate: '/journals/list',
normalizationContext: [ 'groups' => ['read', 'read:list' ]],
),
new Post(
uriTemplate: '/journals/clone',
input: CloneDTO::class,
processor: CloneProcessor::class,
security: 'is_granted("' . Actions::CLONE .'")',
securityMessage: CloneVoter::MESSAGE
),
new Post(),
new Get(),
new Get(
name: 'get_journal_crossref',
uriTemplate: '/journals/{uuid}/export/crossref',
controller: JournalCrossrefExporter::class
),
new Get(
name: 'get_journal_simcheck_crossref',
uriTemplate: '/journals/{uuid}/export/simcheck_crossref',
controller: JournalSimcheckCrossrefExporter::class
),
new Get(
name: 'get_journal_licence_fulltext_crossref',
uriTemplate: '/journals/{uuid}/export/licence_fulltext_crossref',
controller: JournalLicenceFulltextCrossrefExporter::class
),
new Put(),
new Delete(
securityPostDenormalize: 'is_granted("' . Actions::DELETE . '", object)',
securityPostDenormalizeMessage: ArchivableVoter::MESSAGE
),
],
extraProperties: ['standard_put' => false],
)]
#[ApiFilter(SearchFilter::class, properties: [
'translations.title' => 'partial',
'nativeTitle' => 'partial',
'data.workingTitle' => 'partial',
'data.issn' => 'exact',
'data.eIssn' => 'exact',
])]
#[ApiFilter(RangeFilter::class, properties: ['meinScore'])]
#[ApiFilter(DateFilter::class, properties: ['updatedAt'])]
#[ApiFilter(IriFilter::class, properties: [
'nativeLanguage',
'domains.domain',
'affiliations.affiliation',
'data.periodicity',
'data.type',
'data.licence',
'data.state'
])]
#[ApiFilter(BooleanFilter::class, properties: ['isArchived', 'stat'])]
#[ApiFilter(OrderFilter::class, properties: [
'nativeTitle',
'nativeLanguage',
'data.workingTitle',
'data.periodicity',
'updatedAt',
'stat',
'ord'
])]
#[Index(fields: ["nativeLanguage"], name: "native_language_idx")]
#[Index(fields: ["stat"], name: "stat_idx")]
#[ORM\Entity(repositoryClass: JournalRepository::class)]
class Journal implements
TranslatableInterface,
OrdStatableInterface,
LanguageableInterface,
EditorialGroupableInterface,
ArchivableInterface,
OwnerableInterface,
CloneableInterface
{
use IdTrait,
UuidTrait,
OrdStatTrait,
TimestampableTrait,
TranslatableTrait,
JournalLanguagesTrait,
ArchivedTrait,
OwnerTrait,
EditorialGroupableTrait,
ImportIdTrait;
#[ApiProperty(description: 'Native title sort key')]
#[Groups(['read:' . self::class])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $nativeTitleSortKey = null;
#[ApiProperty(description: 'Data subresource', writable: true)]
#[Groups(['read:'. self::class, 'read:list', 'write'])]
#[Assert\Valid]
#[DenormalizationInject(method: ['name' => 'getData'])]
#[ORM\OneToOne(targetEntity: JournalData::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
private JournalData $data;
#[ApiProperty(description: 'View subresource', writable: true)]
#[Groups(['read:' . self::class, 'write'])]
#[Assert\Valid]
#[DenormalizationInject(method: ['name' => 'getView'])]
#[ORM\OneToOne(targetEntity: JournalView::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
private JournalView $view;
#[ApiProperty(description: 'Slug')]
#[Groups(['read:' . self::class, 'write'])]
#[Gedmo\Slug(separator: '-', style: 'default', updatable: true, fields: ['nativeTitle'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $slug = null;
#[ApiProperty(description: 'Slug')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $importSlug = null;
#[ApiProperty(description: 'Slug')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $importSlugEn = null;
#[ApiProperty(description: 'Scientific council members', writableLink: false)]
#[ORM\OneToMany(targetEntity: JournalScientificCouncilMember::class, mappedBy: 'parent', cascade: ['persist'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $scientificCouncilMembers;
#[ApiProperty(description: 'Domains', fetchEager: false)]
#[Groups(['read', 'read:list'])]
#[ORM\OneToMany(targetEntity: JournalDomain::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $domains;
#[ApiProperty(description: 'Indexation collections')]
#[ORM\OneToMany(targetEntity: JournalIndexationCollection::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $indexationCollections;
#[ApiProperty(description: 'Indicators')]
#[ORM\OneToMany(targetEntity: JournalIndicator::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $indicators;
#[ApiProperty(description: 'Affiliations', fetchEager: false)]
#[Groups(['read','read:list'])]
#[ORM\OneToMany(targetEntity: JournalAffiliation::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $affiliations;
#[ApiProperty(description: 'Publishers')]
#[ORM\OneToMany(targetEntity: JournalPublisher::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $publishers;
#[ApiProperty(description: 'Partners')]
#[ORM\OneToMany(targetEntity: JournalPartner::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $partners;
#[ApiProperty(description: 'Slides')]
#[ORM\OneToMany(targetEntity: JournalSlide::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $slides;
#[ApiProperty(description: 'Sections')]
#[ORM\OneToMany(targetEntity: JournalSection::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $sections;
#[ApiProperty(description: 'Menu items')]
#[ORM\OneToMany(targetEntity: JournalMenuItem::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $menuItems;
#[ApiProperty(description: 'Submenu groups')]
#[ORM\OneToMany(targetEntity: JournalSubmenuGroup::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $submenuGroups;
#[ApiProperty(description: 'Sidemenu groups')]
#[ORM\OneToMany(targetEntity: JournalSidemenuGroup::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $sidemenuGroups;
#[ApiProperty(description: 'Banners')]
#[ORM\OneToMany(targetEntity: JournalBanner::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $banners;
#[ApiProperty(description: 'Volumes')]
#[ORM\OneToMany(targetEntity: JournalVolume::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $volumes;
#[ApiProperty(description: 'Issues')]
#[ORM\OneToMany(targetEntity: JournalIssue::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $issues;
#[ApiProperty(description: 'Articles')]
#[ORM\OneToMany(targetEntity: JournalArticle::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $articles;
#[ApiProperty(description: 'Pages')]
#[ORM\OneToMany(targetEntity: JournalPage::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $pages;
#[ApiProperty(description: 'News')]
#[ORM\OneToMany(targetEntity: JournalNews::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $news;
#[ApiProperty(description: 'Collections')]
#[ORM\OneToMany(targetEntity: JournalCollection::class, mappedBy: 'parent', cascade: ['persist', 'remove'])]
#[ORM\OrderBy(['ord' => 'desc'])]
private Collection $collections;
#[ApiProperty(description: 'Sort article by ord')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $sortArticlesByOrd = false;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: JournalFooter::class, orphanRemoval: true)]
private Collection $smallFooters;
public function __construct(Admin $createdBy, ?array $languages)
{
$this->setUuid();
$this->data = new JournalData($this);
$this->view = new JournalView($this);
$this->createdBy = $createdBy;
$this->updatedBy = $createdBy;
$this->translations = new ArrayCollection();
$this->domains = new ArrayCollection();
$this->indexationCollections = new ArrayCollection();
$this->indicators = new ArrayCollection();
$this->affiliations = new ArrayCollection();
$this->publishers = new ArrayCollection();
$this->partners = new ArrayCollection();
$this->slides = new ArrayCollection();
$this->editorialGroups = new ArrayCollection();
$this->scientificCouncilMembers = new ArrayCollection();
$this->sections = new ArrayCollection();
$this->menuItems = new ArrayCollection();
$this->submenuGroups = new ArrayCollection();
$this->sidemenuGroups = new ArrayCollection();
$this->banners = new ArrayCollection();
$this->volumes = new ArrayCollection();
$this->issues = new ArrayCollection();
$this->articles = new ArrayCollection();
$this->pages = new ArrayCollection();
$this->news = new ArrayCollection();
$this->collections = new ArrayCollection();
$this->setLanguages($languages ?? Language::DEFAULT_JOURNAL);
foreach (array_reverse(JournalDefaultPage::cases()) as $index => $idName) {
new JournalPage(
parent: $this,
workingTitle: $idName->value,
idName: $idName->value,
ord: $index + 1,
stat: true
);
}
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
$this->smallFooters = new ArrayCollection();
}
public function getTitle(): string
{
return $this->data->getWorkingTitle();
}
public function setNativeTitleSortKey(string $nativeTitleSortKey): self
{
$this->nativeTitleSortKey = $nativeTitleSortKey;
return $this;
}
public function getNativeTitleSortKey(): ?string
{
return $this->nativeTitleSortKey;
}
public function getData(): JournalData
{
return $this->data;
}
public function getView(): JournalView
{
return $this->view;
}
public function getCover(Language $lang): ?Media
{
if ($this->view->getCoverType() === JournalCoverType::CHOSEN) {
return $this->readAvailableTranslation($lang, 'cover');
}
if ($cover = $this->getNewestIssue()?->readAvailableTranslation($lang, 'cover')) {
return $cover;
}
return $this->view->getCoverType() === JournalCoverType::CURRENT_ISSUE_OR_CHOSEN
? $this->readAvailableTranslation($lang, 'cover')
: null;
}
public function getCoverAlt(Language $lang): ?string
{
if ($this->view->getCoverType() === JournalCoverType::CHOSEN) {
return $this->readAvailableTranslation($lang, 'coverAlt');
}
if ($this->getNewestIssue()?->readAvailableTranslation($lang, 'cover')) {
return $this->getNewestIssue()?->readAvailableTranslation($lang, 'coverAlt');
}
return $this->view->getCoverType() === JournalCoverType::CURRENT_ISSUE_OR_CHOSEN
? $this->readAvailableTranslation($lang, 'coverAlt')
: null;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getImportSlug(): ?string
{
return $this->importSlug;
}
public function setImportSlug(?string $importSlug): self
{
$this->importSlug = $importSlug;
return $this;
}
public function getImportSlugEn(): ?string
{
return $this->importSlugEn;
}
public function setImportSlugEn(?string $importSlugEn): self
{
$this->importSlugEn = $importSlugEn;
return $this;
}
/**
* @return Collection|JournalScientificCouncilMember[]
*/
public function getScientificCouncilMembers(): Collection
{
return $this->scientificCouncilMembers;
}
public function addScientificCouncilMember(JournalScientificCouncilMember $scientificCouncilMember): self
{
if ($this->scientificCouncilMembers->contains($scientificCouncilMember)) {
return $this;
}
$this->scientificCouncilMembers[] = $scientificCouncilMember;
return $this;
}
public function removeScientificCouncilMember(JournalScientificCouncilMember $scientificCouncilMember): self
{
$this->scientificCouncilMembers->removeElement($scientificCouncilMember);
return $this;
}
public function resetScientificCouncilMembers(): self
{
$this->scientificCouncilMembers = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalDomain[]
*/
public function getDomains(): Collection
{
return $this->domains;
}
public function addDomain(JournalDomain $domain): self
{
if ($this->domains->contains($domain)) {
return $this;
}
$this->domains[] = $domain;
return $this;
}
public function removeDomain(JournalDomain $domain): self
{
$this->domains->removeElement($domain);
return $this;
}
public function resetDomains(): self
{
$this->domains = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalIndexationCollection[]
*/
public function getIndexationCollections(): Collection
{
return $this->indexationCollections;
}
public function addIndexationCollection(JournalIndexationCollection $indexationCollection): self
{
if ($this->indexationCollections->contains($indexationCollection)) {
return $this;
}
$this->indexationCollections[] = $indexationCollection;
return $this;
}
public function removeIndexationCollection(JournalIndexationCollection $indexationCollection): self
{
$this->indexationCollections->removeElement($indexationCollection);
return $this;
}
public function resetIndexationCollections(): self
{
$this->indexationCollections = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalIndicator[]
*/
public function getIndicators(): Collection
{
return $this->indicators;
}
public function addIndicator(JournalIndicator $indicator): self
{
if ($this->indicators->contains($indicator)) {
return $this;
}
$this->indicators[] = $indicator;
return $this;
}
public function removeIndicator(JournalIndicator $indicator): self
{
$this->indicators->removeElement($indicator);
return $this;
}
public function resetIndicators(): self
{
$this->indicators = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalAffiliation[]
*/
public function getAffiliations(): Collection
{
return $this->affiliations;
}
public function addAffiliation(JournalAffiliation $affiliation): self
{
if ($this->affiliations->contains($affiliation)) {
return $this;
}
$this->affiliations[] = $affiliation;
return $this;
}
public function removeAffiliation(JournalAffiliation $affiliation): self
{
$this->affiliations->removeElement($affiliation);
return $this;
}
public function resetAffiliations(): self
{
$this->affiliations = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalPublisher[]
*/
public function getPublishers(): Collection
{
return $this->publishers;
}
public function addPublisher(JournalPublisher $publisher): self
{
if ($this->publishers->contains($publisher)) {
return $this;
}
$this->publishers[] = $publisher;
return $this;
}
public function removePublisher(JournalPublisher $publisher): self
{
$this->publishers->removeElement($publisher);
return $this;
}
public function resetPublishers(): self
{
$this->publishers = new ArrayCollection();
return $this;
}
public function getVisiblePublishers(): Collection
{
return $this->publishers->filter(
fn (JournalPublisher $publisher) =>
$publisher->getStat() === true &&
$publisher->getPublisher()->getStat() === true
);
}
/**
* @return Collection|JournalPartner[]
*/
public function getPartners(): Collection
{
return $this->partners;
}
public function addPartner(JournalPartner $partner): self
{
if ($this->partners->contains($partner)) {
return $this;
}
$this->partners[] = $partner;
return $this;
}
public function removePartner(JournalPartner $partner): self
{
$this->partners->removeElement($partner);
return $this;
}
public function resetPartners(): self
{
$this->partners = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalSlide[]
*/
public function getSlides(): Collection
{
return $this->slides;
}
public function addSlide(JournalSlide $slide): self
{
if ($this->slides->contains($slide)) {
return $this;
}
$this->slides[] = $slide;
return $this;
}
public function removeSlide(JournalSlide $slide): self
{
$this->slides->removeElement($slide);
return $this;
}
public function resetSlides(): self
{
$this->slides = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalSection[]
*/
public function getSections(): Collection
{
return $this->sections;
}
public function addSection(JournalSection $section): self
{
if ($this->sections->contains($section)) {
return $this;
}
$this->sections[] = $section;
return $this;
}
public function removeSection(JournalSection $section): self
{
$this->sections->removeElement($section);
return $this;
}
public function resetSections(): self
{
$this->sections = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalMenuItem[]
*/
public function getMenuItems(): Collection
{
return $this->menuItems;
}
public function addMenuItem(JournalMenuItem $menuItem): self
{
if ($this->menuItems->contains($menuItem)) {
return $this;
}
$this->menuItems[] = $menuItem;
return $this;
}
public function removeMenuItem(JournalMenuItem $menuItem): self
{
$this->menuItems->removeElement($menuItem);
return $this;
}
public function resetMenuItems(): self
{
$this->menuItems = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalSubmenuGroup[]
*/
public function getSubmenuGroups(): Collection
{
return $this->submenuGroups;
}
public function addSubmenuGroup(JournalSubmenuGroup $submenuGroup): self
{
if ($this->submenuGroups->contains($submenuGroup)) {
return $this;
}
$this->submenuGroups[] = $submenuGroup;
return $this;
}
public function removeSubmenuGroup(JournalSubmenuGroup $submenuGroup): self
{
$this->submenuGroups->removeElement($submenuGroup);
return $this;
}
public function resetSubmenuGroups(): self
{
$this->submenuGroups = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalSidemenuGroup[]
*/
public function getSidemenuGroups(): Collection
{
return $this->sidemenuGroups;
}
public function addSidemenuGroup(JournalSidemenuGroup $sidemenuGroup): self
{
if ($this->sidemenuGroups->contains($sidemenuGroup)) {
return $this;
}
$this->sidemenuGroups[] = $sidemenuGroup;
return $this;
}
public function removeSidemenuGroup(JournalSidemenuGroup $sidemenuGroup): self
{
$this->sidemenuGroups->removeElement($sidemenuGroup);
return $this;
}
public function resetSidemenuGroups(): self
{
$this->sidemenuGroups = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalBanner[]
*/
public function getBanners(): Collection
{
return $this->banners;
}
public function addBanner(JournalBanner $banner): self
{
if ($this->banners->contains($banner)) {
return $this;
}
$this->banners[] = $banner;
return $this;
}
public function removeBanner(JournalBanner $banner): self
{
$this->banners->removeElement($banner);
return $this;
}
public function resetBanners(): self
{
$this->banners = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalVolume[]
*/
public function getVolumes(): Collection
{
return $this->volumes;
}
public function addVolume(JournalVolume $volume): self
{
if ($this->volumes->contains($volume)) {
return $this;
}
$this->volumes[] = $volume;
return $this;
}
public function removeVolume(JournalVolume $volume): self
{
$this->volumes->removeElement($volume);
return $this;
}
public function resetVolumes(): self
{
$this->volumes = new ArrayCollection();
return $this;
}
/**
* @return Collection<int, JournalIssue>
*/
public function getIssues(): Collection
{
return $this->issues;
}
/**
* @return Collection<int, JournalIssue>
*/
public function getVisibleIssues(): Collection
{
return $this->issues->filter(fn (JournalIssue $issue) => $issue->getStat());
}
public function addIssue(JournalIssue $issue): self
{
if ($this->issues->contains($issue)) {
return $this;
}
$this->issues[] = $issue;
return $this;
}
public function removeIssue(JournalIssue $issue): self
{
$this->issues->removeElement($issue);
return $this;
}
public function resetIssues(): self
{
$this->issues = new ArrayCollection();
return $this;
}
public function getNewestIssue(): ?JournalIssue
{
foreach ($this->getIssues() as $issue) {
if ($issue->getStat() && $issue->getIsNewestIssue()) {
return $issue;
}
}
return null;
}
public function getOldestIssue(): ?JournalIssue
{
$filtered = new ArrayCollection();
foreach ($this->getIssues() as $issue) {
if ($issue->getStat() && $issue->getPublishedAt()) {
$filtered->add($issue);
}
}
if (count($filtered) === 0) {
return null;
}
$criteria = Criteria::create()->orderBy(['publishedAt' => Criteria::ASC]);
return $filtered
->matching($criteria)
->first();
}
/**
* @return Collection|JournalArticle[]
*/
public function getArticles(): Collection
{
return $this->articles;
}
/**
* @return Collection<int, JournalArticle>
*/
public function getArticlesVisible(): Collection
{
return $this->articles->filter(fn (JournalArticle $article) => $article->getStat());
}
public function addArticle(JournalArticle $article): self
{
if ($this->articles->contains($article)) {
return $this;
}
$this->articles[] = $article;
return $this;
}
public function removeArticle(JournalArticle $article): self
{
$this->articles->removeElement($article);
return $this;
}
public function resetArticles(): self
{
$this->articles = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalPage[]
*/
public function getPages(): Collection
{
return $this->pages;
}
public function addPage(JournalPage $page): self
{
if ($this->pages->contains($page)) {
return $this;
}
$this->pages[] = $page;
return $this;
}
public function removePage(JournalPage $page): self
{
$this->pages->removeElement($page);
return $this;
}
public function resetPages(): self
{
$this->pages = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalNews[]
*/
public function getNews(): Collection
{
return $this->news;
}
public function addNews(JournalNews $news): self
{
if ($this->news->contains($news)) {
return $this;
}
$this->news[] = $news;
return $this;
}
public function removeNews(JournalNews $news): self
{
$this->news->removeElement($news);
return $this;
}
public function resetNews(): self
{
$this->news = new ArrayCollection();
return $this;
}
/**
* @return Collection|JournalCollection[]
*/
public function getCollections(): Collection
{
return $this->collections;
}
public function addCollection(JournalCollection $collection): self
{
if ($this->collections->contains($collection)) {
return $this;
}
$this->collections[] = $collection;
return $this;
}
public function removeCollection(JournalCollection $news): self
{
$this->news->removeElement($news);
return $this;
}
public function resetCollections(): self
{
$this->collections = new ArrayCollection();
return $this;
}
public function clone(Admin $createdBy = null): self
{
$clone = clone $this;
$clone->id = null;
$clone->setUuid();
$clone->ord = 0;
$clone->stat = false;
$clone->importId = null;
$clone->data = $this->data->clone($clone);
$clone->view = $this->view->clone($clone);
$nativeLanguage = $clone->getNativeLanguage();
$nativeTranslation = $clone->getTranslation($nativeLanguage);
$nativeTranslation->setTitle($nativeTranslation->getTitle() . ' [KOPIA]');
ClassUtils::cloneCollection($this, $clone, 'translations');
$clone
->resetDomains()
->resetIndexationCollections()
->resetIndicators()
->resetAffiliations()
->resetPublishers()
->resetPartners()
->resetSlides()
->resetSections()
->resetMenuItems()
->resetSubmenuGroups()
->resetBanners()
->resetVolumes()
->resetIssues()
->resetArticles()
->resetPages()
->resetNews()
->resetCollections()
->resetEditorialGroups()
->resetScientificCouncilMembers();
$clone->createdBy = $createdBy ?? $clone->createdBy;
$clone->updatedBy = $createdBy ?? $clone->updatedBy;
$clone->createdAt = new \DateTimeImmutable();
$clone->updatedAt = new \DateTimeImmutable();
return $clone;
}
public function isSortArticlesByOrd(): bool
{
return $this->sortArticlesByOrd;
}
public function setSortArticlesByOrd(bool $sortArticlesByOrd): self
{
$this->sortArticlesByOrd = $sortArticlesByOrd;
return $this;
}
/**
* @return Collection<int, JournalFooter>
*/
public function getSmallFooters(): Collection
{
return $this->smallFooters;
}
public function addSmallFooter(JournalFooter $smallFooter): self
{
if (!$this->smallFooters->contains($smallFooter)) {
$this->smallFooters->add($smallFooter);
$smallFooter->setParent($this);
}
return $this;
}
public function removeSmallFooter(JournalFooter $smallFooter): self
{
if ($this->smallFooters->removeElement($smallFooter)) {
// set the owning side to null (unless already changed)
if ($smallFooter->getParent() === $this) {
$smallFooter->setParent(null);
}
}
return $this;
}
public function getVisibleSmallFooters(): Collection
{
return $this->smallFooters->filter(fn (JournalFooter $smallFooter) => $smallFooter->getStat());
}
}