/** * {@inheritDoc} */ public function getThemePath() { $issue = $this->issueService->getIssue(); if (!$issue) { return; } $languageId = $issue->getLanguageId(); $publication = $this->publicationService->getPublication(); $cacheKeyThemePath = $this->cacheService->getCacheKey(array('getThemePath', $languageId, $publication->getId(), $issue->getNumber()), 'issue'); $themePath = null; $webOutput = null; $outSetIssues = null; if ($this->cacheService->contains($cacheKeyThemePath)) { $themePath = $this->cacheService->fetch($cacheKeyThemePath); } else { $cacheKeyWebOutput = $this->cacheService->getCacheKey(array('OutputService', 'Web'), 'outputservice'); if ($this->cacheService->contains($cacheKeyWebOutput)) { $webOutput = $this->cacheService->fetch($cacheKeyWebOutput); } else { $webOutput = $this->findByName('Web'); $this->cacheService->save($cacheKeyWebOutput, $webOutput); } $outSetIssues = $this->findByIssueAndOutput($issue->getId(), $webOutput); if (!is_null($outSetIssues)) { $themePath = $outSetIssues->getThemePath()->getPath(); } $this->cacheService->save($cacheKeyThemePath, $themePath); } return $themePath; }
public function let(EntityManager $em, PublicationService $publicationService, IssueRepository $repository, Issue $issue, Publication $publication, AbstractQuery $query, CacheService $cacheService) { $em->getRepository('Newscoop\\Entity\\Issue')->willReturn($repository); $publicationService->getPublication()->willReturn($publication); $repository->findOneBy(array('publication' => $publication, 'shortName' => 'may2014'))->willReturn($issue); $repository->getIssue('en', $publication, 'may2014')->willReturn($query); $query->getOneOrNullResult()->willReturn($issue); $this->beConstructedWith($em, $publicationService, $cacheService); }
/** * {@inheritDoc} */ public function getLatestPublishedIssue() { $publication = $this->publicationService->getPublication(); if (!$publication) { return; } $issues = $publication->getIssues(); if (!$issues) { return; } $issues = $issues->toArray(); usort($issues, function ($x, $y) { return $y->getId() - $x->getId(); }); $latestPublished = false; $latestPublishedIssue = null; foreach ($issues as $key => $issue) { if ($issue->getWorkflowStatus() === 'Y' && !$latestPublished) { $latestPublishedIssue = $issue; $latestPublished = true; } } if (null !== $latestPublishedIssue) { $this->setIssue($latestPublishedIssue); } return $latestPublishedIssue; }
private function preconfigureVector() { $publicationMetadata = $this->publicationService->getPublicationMetadata(); if (count($publicationMetadata) > 0) { $this->smarty->campsiteVector = array_merge($this->originalVector, array('publication' => $publicationMetadata['alias']['publication_id'], 'language' => $publicationMetadata['publication']['id_default_language'])); } }
public function let(IssueServiceInterface $issueService, Issue $issue, CacheService $cacheService, PublicationService $publicationService, Publication $publication, EntityManager $em, Registry $doctrine, EntityRepository $repository, Output $output, OutputSettingsIssue $issueOutput) { $issueService->getIssue()->willReturn($issue); $publicationService->getPublication()->willReturn($publication); $doctrine->getManager()->willReturn($em); $em->getRepository(Argument::exact('Newscoop\\Entity\\Output'))->willReturn($repository); $repository->findBy(array('name' => 'Web'))->willReturn(array($output)); $em->getRepository(Argument::exact('Newscoop\\Entity\\Output\\OutputSettingsIssue'))->willReturn($repository); $repository->findBy(array('issue' => 1, 'output' => 1))->willReturn(array($issueOutput)); $issue->getId()->willReturn(1); $issue->getNumber()->willReturn(10); $issue->getName()->willReturn("May 2014"); $issue->getShortName()->willReturn("may2014"); $issue->getLanguageId()->willReturn(1); $output->getId()->willReturn(1); $output->getName()->willReturn('Web'); $this->beConstructedWith($issueService, $cacheService, $publicationService, $em); }
/** * {@inheritDoc} */ public function getLatestPublishedIssue() { $publication = $this->publicationService->getPublication(); if (!$publication) { return; } $publicationId = $publication->getId(); $cacheKey = $this->cacheService->getCacheKey(array('latest_published', $publicationId), 'issue'); if ($this->cacheService->contains($cacheKey)) { $issue = $this->cacheService->fetch($cacheKey); } else { $issue = $this->em->getRepository('Newscoop\\Entity\\Issue')->getLastPublishedByPublication($publicationId)->getArrayResult(); $this->cacheService->save($cacheKey, $issue); } if (empty($issue)) { return; } $latestPublishedIssue = $this->em->getReference('Newscoop\\Entity\\Issue', $issue[0]['id']); $this->setIssue($latestPublishedIssue); return $latestPublishedIssue; }
public function onRequest(GetResponseEvent $event) { if ($event->getRequest()->get('_route') != 'newscoop_get_img') { $this->publicationService->publicationResolver($event->getRequest()); } }
public function let(EntityManager $em, PublicationService $publicationService, IssueRepository $repository, Issue $issue, Publication $publication, AbstractQuery $query, CacheService $cacheService) { $em->getRepository('Newscoop\\Entity\\Issue')->willReturn($repository); $publicationService->getPublication()->willReturn($publication); $this->beConstructedWith($em, $publicationService, $cacheService); }