/**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && array_key_exists($field, $data)) {
         return $this->isValid($data[$field], $field, $extra);
     }
     return $this->articleRepository->resultExists($data);
 }
 public function fetchSitemapUrls()
 {
     $this->addUrl('articles/index/index');
     foreach ($this->articleRepository->getAll($this->date->getCurrentDateTime()) as $result) {
         $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
     }
 }
예제 #3
0
 /**
  * @param int $id
  * @return array
  */
 public function execute($id)
 {
     if ($this->articleRepository->resultExists((int) $id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         return ['sidebar_article' => $this->articlesCache->getCache($id)];
     }
 }
예제 #4
0
 /**
  * @return array
  */
 public function execute()
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $resultsPerPage = $this->resultsPerPage->getResultsPerPage(Articles\Installer\Schema::MODULE_NAME);
     $time = $this->date->getCurrentDateTime();
     $this->pagination->setResultsPerPage($resultsPerPage)->setTotalResults($this->articleRepository->countAll($time));
     $articles = $this->articleRepository->getAll($time, $this->pagination->getResultsStartOffset(), $resultsPerPage);
     return ['articles' => $articles, 'pagination' => $this->pagination->render()];
 }
예제 #5
0
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->articleRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $article = $this->articlesCache->getCache($id);
         $this->breadcrumb->replaceAncestor($article['title'], '', true);
         return ['page' => array_merge($article, $this->pageBreaksHelper->splitTextIntoPages($this->view->fetchStringAsTemplate($article['text']), $this->request->getUriWithoutPages()))];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
예제 #6
0
 /**
  * @param string $template
  * @return array
  */
 public function execute($template = '')
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $this->setTemplate($template);
     return ['sidebar_articles' => $this->articleRepository->getAll($this->date->getCurrentDateTime(), 5)];
 }
예제 #7
0
 /**
  * @param integer $articleId
  *
  * @return boolean
  */
 public function saveCache($articleId)
 {
     return $this->cache->save(self::CACHE_ID . $articleId, $this->articleRepository->getOneById($articleId));
 }
예제 #8
0
 /**
  * @param int $id
  *
  * @return bool
  */
 public function articleExists($id)
 {
     return $this->articleRepository->resultExists($id);
 }