Пример #1
0
 public function onIssueFileDownload(DownloadIssueFileEvent $event)
 {
     $issueFile = $event->getIssueFile();
     $issue = $issueFile->getIssue();
     $journal = $issue->getJournal();
     $stat = $this->em->getRepository('OjsAnalyticsBundle:IssueFileStatistic')->findOneBy(['date' => new \DateTime(), 'issueFile' => $issueFile]);
     if (!$stat) {
         $stat = new IssueFileStatistic();
         $stat->setDate(new \DateTime());
         $stat->setIssueFile($issueFile);
         $stat->setDownload(1);
     } else {
         $stat->setDownload($stat->getDownload() + 1);
     }
     $issue->increaseDownloadCount();
     $journal->increaseDownloadCount();
     $this->em->persist($journal);
     $this->em->persist($stat);
     $this->em->flush();
 }
Пример #2
0
 public function onIssueFileDownload(DownloadIssueFileEvent $event)
 {
     $stat = $this->em->getRepository('OjsAnalyticsBundle:IssueFileStatistic')->findOneBy(['date' => new \DateTime(), 'issueFile' => $event->getIssueFile()]);
     if (!$stat) {
         $stat = new IssueFileStatistic();
         $stat->setDate(new \DateTime());
         $stat->setIssueFile($event->getIssueFile());
         $stat->setDownload(1);
     } else {
         $stat->setDownload($stat->getDownload() + 1);
     }
     $this->em->persist($stat);
     $this->em->flush($stat);
 }
Пример #3
0
 public function onIssueFileDownload(DownloadIssueFileEvent $event)
 {
     $request = $this->requestStack->getMasterRequest();
     $session = $request->getSession();
     $issueFile = $event->getIssueFile();
     $sessionKey = 'download_issue_file_' . $issueFile->getId();
     if ($session->has($sessionKey)) {
         return;
     } else {
         $session->set($sessionKey, 1);
     }
     $issue = $issueFile->getIssue();
     $journal = $issue->getJournal();
     $stat = $this->em->getRepository('OjsAnalyticsBundle:IssueFileStatistic')->findOneBy(['date' => new \DateTime(), 'issueFile' => $issueFile]);
     if (!$stat) {
         $stat = new IssueFileStatistic();
         $stat->setDate(new \DateTime());
         $stat->setIssueFile($issueFile);
         $stat->setDownload(1);
     } else {
         $stat->setDownload($stat->getDownload() + 1);
     }
     $issue->increaseDownloadCount();
     $journal->increaseDownloadCount();
     $this->em->persist($journal);
     $this->em->persist($stat);
     $this->em->flush();
 }