public static function numerateArticle(Article $article, ObjectManager $entityManager) { $journal = $article->getJournal(); if ($article->getNumerator() === null) { try { $numerator = $entityManager->getRepository('OjsJournalBundle:Numerator')->getArticleNumerator($journal); $last = $numerator->getLast() + 1; $numerator->setLast($last); $article->setNumerator($last); } catch (NoResultException $exception) { $numerator = new Numerator(); $numerator->setJournal($journal); $numerator->setType('article'); $numerator->setLast(1); $article->setNumerator(1); } $entityManager->persist($article); $entityManager->persist($numerator); $entityManager->flush(); } }
/** * @param Article $article New article entity * @param array $row Supp file row from the source database * @param integer $oldArticleId Old ID of the article * @param string $oldJournalSlug Slug of the article's journal */ public function importSupFile(Article $article, $row, $oldArticleId, $oldJournalSlug) { $settings = $this->getSettings($row["supp_id"]); if (empty($settings)) { return; } $accessor = PropertyAccess::createPropertyAccessor(); $code = $article->getJournal()->getMandatoryLang()->getCode(); $settings = empty($settings[$code]) ? current($settings) : $settings[$code]; $fileFormat = "imported/supplementary/%s/%s.%s"; $extension = !empty($row["file_type"]) ? $accessor->getValue(FileHelper::$mimeToExtMap, "[" . $row["file_type"] . "]") : ""; $filename = sprintf($fileFormat, $oldArticleId, $row["file_id"], $extension); $keywords = mb_substr($accessor->getValue($settings, "[subject]"), 0, 255); $file = new ArticleFile(); $file->setVersion(0); $file->setLangCode($code); $file->setFile($filename); $file->setArticle($article); $file->setKeywords($keywords); $file->setType(ArticleFileParams::SUPPLEMENTARY_FILE); $file->setTitle($accessor->getValue($settings, "[title]")); $file->setDescription($accessor->getValue($settings, "[description]")); $history = $this->em->getRepository(FileHistory::class)->findOneBy(["fileName" => $filename]); if (!$history) { $history = new FileHistory(); $history->setFileName($filename); $history->setType("articlefiles"); $history->setOriginalName($row["original_file_name"]); $this->em->persist($history); } $source = sprintf("%s/article/downloadSuppFile/%s/%s", $oldJournalSlug, $oldArticleId, $row["supp_id"]); $target = sprintf("/../web/uploads/articlefiles/%s", $filename); $download = new PendingDownload(); $download->setSource($source); $download->setTarget($target); $this->em->persist($file); $this->em->persist($download); }
/** * * @param Article $article * @return string */ public function generateUrl(Article $article) { $journalUrl = $this->journalService->generateUrl($article->getJournal()); return $journalUrl . '/' . $article->getSlug(); }
public function articleIdAction(Article $article) { return $this->redirectToRoute('ojs_article_page', ['slug' => $article->getJournal()->getSlug(), 'article_id' => $article->getId(), 'issue_id' => $article->getIssue()->getId()]); }