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;
}