Refactor to multiple clasess start
This commit is contained in:
66
app/modules/Front/Search/SearchPresenter.php
Normal file
66
app/modules/Front/Search/SearchPresenter.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php //declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace App\Modules\Front\Search;
|
||||||
|
|
||||||
|
use App\Modules\Front\BaseFrontPresenter;
|
||||||
|
use Nette;
|
||||||
|
use Nette\Utils\Strings;
|
||||||
|
use Nette\Application\UI;
|
||||||
|
use Dict\OggResponse;
|
||||||
|
use Nette\Application\Responses\JsonResponse;
|
||||||
|
use AlesWita\VisualPaginator\VisualPaginator;
|
||||||
|
use AlesWita\VisualPaginator\VisualPaginatorFactory;
|
||||||
|
use App\Model\Database\EntityManager;
|
||||||
|
use App\Model\Database\Entity\Dictionary;
|
||||||
|
use App\Model\Database\Entity\Translation;
|
||||||
|
use App\Model\Database\Repository\TranslationRepository;
|
||||||
|
use App\Model\Database\Repository\TermsFullQuery;
|
||||||
|
use App\Model\Database\Repository\TermsQuickQuery;
|
||||||
|
use App\Model\Database\Facade\TermFacade;
|
||||||
|
|
||||||
|
class SearchPresenter extends BaseFrontPresenter
|
||||||
|
{
|
||||||
|
/** @inject @var EntityManager */
|
||||||
|
public EntityManager $em;
|
||||||
|
/** @inject */
|
||||||
|
public TermFacade $termFacade;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** @persistent */
|
||||||
|
public $term;
|
||||||
|
|
||||||
|
protected function doSearch($query, $translation, $term, $clen = null, $paginate = true)
|
||||||
|
{
|
||||||
|
$t = $this->em->getTranslationRepository()->find($translation);
|
||||||
|
|
||||||
|
if ($term) $this->term = $term;
|
||||||
|
if ($translation) $this->translation = $translation;
|
||||||
|
// $this->slug = $this->translations[$translation]["slug"];
|
||||||
|
|
||||||
|
$this->termFacade->setDirection(1);
|
||||||
|
|
||||||
|
/* if ($paginate) {
|
||||||
|
$this["paginator"]->setItemCount(500);
|
||||||
|
$offset = $this["paginator"]->getOffset();
|
||||||
|
$itemsPerPage = $this['paginator']->getItemsPerPage();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$q = $this->termFacade->findByString($term, $t->dictionary, $clen);
|
||||||
|
//$q->setMaxResults(500)->setFirstResult($offset)->getMaxResults($itemsPerPage);
|
||||||
|
|
||||||
|
$this->template->translation = $t;
|
||||||
|
|
||||||
|
return $q->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderDefault($translation,$term,$clen,$paginate = false)
|
||||||
|
{
|
||||||
|
$this['searchForm']['string']->setValue($this->term);
|
||||||
|
$this->template->result = $this->doSearch('TermQuery',$translation,$term,$clen,$paginate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user