Exemplo n.º 1
0
 /**
  * @param int $cat
  *
  * @return array
  */
 public function execute($cat = 0)
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $this->addBreadcrumbStep($cat);
     $time = $this->date->getCurrentDateTime();
     $this->pagination->setResultsPerPage($this->resultsPerPage->getResultsPerPage(News\Installer\Schema::MODULE_NAME))->setTotalResults($this->newsRepository->countAll($time, $cat));
     $news = $this->fetchNews($cat, $time);
     $cNews = count($news);
     for ($i = 0; $i < $cNews; ++$i) {
         $news[$i]['text'] = $this->view->fetchStringAsTemplate($news[$i]['text']);
         if ($this->commentsActive === true && $news[$i]['comments'] == 1) {
             $news[$i]['comments_count'] = $this->get('comments.helpers')->commentsCount(News\Installer\Schema::MODULE_NAME, $news[$i]['id']);
         }
         if ($this->newsSettings['readmore'] == 1 && $news[$i]['readmore'] == 1) {
             $news[$i]['text'] = $this->addReadMoreLink($news[$i]);
         }
     }
     return ['news' => $news, 'dateformat' => $this->newsSettings['dateformat'], 'categories' => $this->categoriesHelpers->categoriesList('news', $cat), 'pagination' => $this->pagination->render()];
 }
Exemplo n.º 2
0
 /**
  * @param array $formData
  *
  * @return int
  */
 protected function fetchCategoryIdForSave(array $formData)
 {
     return !empty($formData['cat_create']) ? $this->categoriesHelpers->categoriesCreate($formData['cat_create'], News\Installer\Schema::MODULE_NAME) : $formData['cat'];
 }