// index article entries. // $counter = 0; $articleService = new Stjornvisi\Service\Article($pdo); $articles = $articleService->fetchAll(); $adapter = new Zend\Progressbar\Adapter\Console(); echo "\nIndexing News entries\n"; $progressBar = new Zend\ProgressBar\ProgressBar($adapter, $counter, count($articles)); $i = new Stjornvisi\Search\Index\Article(); foreach ($articles as $item) { $i->index($item, $index); $progressBar->update(++$counter); } $index->commit(); $progressBar->finish(); //Group // index group entries. // $counter = 0; $groupService = new Stjornvisi\Service\Group($pdo); $groups = $groupService->fetchAll(); $adapter = new Zend\Progressbar\Adapter\Console(); echo "\nIndexing Group entries\n"; $progressBar = new Zend\ProgressBar\ProgressBar($adapter, $counter, count($groups)); $i = new Stjornvisi\Search\Index\Group(); foreach ($groups as $item) { $i->index($item, $index); $progressBar->update(++$counter); } $index->commit(); $progressBar->finish();
/** * @param $group_id * @return \Stjornvisi\Service\Group * @throws NotifyException * @throws \Stjornvisi\Service\Exception */ private function getGroup($group_id) { $groupService = new \Stjornvisi\Service\Group(); $groupService->setDataSource($this->getDataSourceDriver())->setEventManager($this->getEventManager()); if (($group = $groupService->get($group_id)) != false) { return $group; } else { throw new NotifyException("Group [{$group_id}] not found"); } }