Fixes nette3

This commit is contained in:
2022-01-16 21:51:34 +01:00
parent d14b1eccde
commit 849aa6d5b1
8 changed files with 221 additions and 39 deletions

View File

@@ -1,7 +1,8 @@
<?php declare(strict_types = 1);
<?php //declare(strict_types = 1);
namespace App\Modules\Front\Home;
use App\Modules\Front\BaseFrontPresenter;
use Nette;
use Nette\Utils\Strings;
use Nette\Application\UI;
@@ -9,25 +10,16 @@ use Dict\OggResponse;
use Nette\Application\Responses\JsonResponse;
use AlesWita\VisualPaginator\VisualPaginator;
use AlesWita\VisualPaginator\VisualPaginatorFactory;
use App\Modules\Front\BaseFrontPresenter;
use App\Model\Database\EntityManager;
use App\Model\Database\Entity\Dictionary;
use App\Model\Database\Entity\Translation;
use App\Model\Database\Repository\TranslationRepository;
final class HomePresenter extends BaseFrontPresenter
{
/** @inject @var \App\Translations */
public $repoTranslations;
/** @inject @var \App\Pronunciations */
public $repoPronunciations;
/** @inject @var \App\Dictionaries */
public $repoDictionaries;
/** @inject @var \App\DictTypes */
public $repoDictTypes;
/** @inject @var \App\Terms */
public $repoTerms;
/** @inject @var \App\TermFlags */
public $repoTermFlags;
/** @inject @var \App\Model\Database\EntityManager */
public $em;
private $translations;
private $dictionaries;
@@ -42,8 +34,8 @@ final class HomePresenter extends BaseFrontPresenter
protected function startup()
{
$trs = $this->repoTranslations->findBy([],['id' => 'ASC','direction'=>'ASC']);
$drs = $this->repoDictionaries->findPairs([],'name',[],'id');
$trs = $this->em->getRepository(Translation::class)->findBy([],['id' => 'ASC','direction'=>'ASC']);
$drs = $this->em->getRepository(Dictionary::class)->findPairs([],'name',[],'id');
$select = [];
foreach ($trs as $t) {
$lang1 = $t->langName1;
@@ -69,7 +61,7 @@ final class HomePresenter extends BaseFrontPresenter
protected function doSearch($query,$translation,$term,$clen = null,$paginate = true)
{
$t = $this->repoTranslations->find($translation);
$t = $this->em->getTranslationRepository()->find($translation);
if ($term) $this->term = $term;
if ($translation) $this->translation = $translation;
@@ -125,7 +117,7 @@ final class HomePresenter extends BaseFrontPresenter
$clen = $values->clen;
$term = $values->string;
$result = $this->doSearch('\\App\\TermsQuery',$translation,$term,$clen);
$result = $this->doSearch('\\App\\Model\\Database\\Repository\\TermsQuery',$translation,$term,$clen);
$this->template->result = $result;
}
@@ -153,7 +145,7 @@ final class HomePresenter extends BaseFrontPresenter
public function actionPlay($id = null)
{
$pron = $this->repoPronunciations->find(['id'=>$id]);
$pron = $this->em->getPronunciationRepository()->find(['id'=>$id]);
$basepath = $this->getHttpRequest()->url->basePath . "/media";
$oggResp = new OggResponse($id,$pron->filename);
return $this->sendResponse($oggResp);
@@ -174,7 +166,7 @@ final class HomePresenter extends BaseFrontPresenter
if ($this->getRequest()->isMethod('GET') && $this->term) {
$this['searchForm']['string']->setValue($this->term);
$t = $this->slugs[$this->slug];
$result = $this->doSearch('\\App\\TermsQuery',$t->id,$this->term);
$result = $this->doSearch('\\App\\Model\\Database\\Repository\\TermsQuery',$t->id,$this->term);
if ($result) $this->template->result = $result;
}
@@ -279,4 +271,4 @@ final class HomePresenter extends BaseFrontPresenter
}
}
}