/** * @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')); } }
/** * @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)]; } }
/** * @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()]; }
/** * @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(); }
/** * @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)]; }
/** * @param integer $articleId * * @return boolean */ public function saveCache($articleId) { return $this->cache->save(self::CACHE_ID . $articleId, $this->articleRepository->getOneById($articleId)); }
/** * @param int $id * * @return bool */ public function articleExists($id) { return $this->articleRepository->resultExists($id); }