Skip to content

Commit

Permalink
router
Browse files Browse the repository at this point in the history
  • Loading branch information
vanekm committed Jul 5, 2024
1 parent 1f10b74 commit 356a4d9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
11 changes: 9 additions & 2 deletions app/Modules/Fykos/DefaultModule/ResultsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
use App\Models\Downloader\FKSDBDownloader;
use Fykosak\FKSDBDownloaderCore\Requests\SeriesResultsRequest;

use Nette\Application\Attributes\Persistent;
use Tracy\Debugger;

class ResultsPresenter extends BasePresenter
{
/** @persistent */
public ?int $year = self::CURRENT_YEAR;
#[Persistent]
public ?int $year;


private readonly FKSDBDownloader $downloader;

public function injectDownloader(FKSDBDownloader $downloader): void
Expand All @@ -23,6 +28,8 @@ public function injectDownloader(FKSDBDownloader $downloader): void
*/
public function renderDefault(): void
{
Debugger::barDump($this->year);

$year = $this->year ?? self::CURRENT_YEAR;
$this->template->year = $year;
$this->template->results = $this->downloader->download(new SeriesResultsRequest(1, $year, 1));
Expand Down
51 changes: 20 additions & 31 deletions app/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,39 +174,27 @@ public static function createDsefRouter(?array $domainList, array $routerMapping
null => self::useTranslateFilter($domainList, $routerMapping['archive']),
]);

$router->withModule('Default')
->addRoute('//<domain>/(international|erasmus)', [
'presenter' => 'Erasmus',
'lang' => 'cs',
null => self::havingDomainLanguage(['cs'], $domainList),
], $router::ONE_WAY)
->addRoute('//<domain>/<presenter>[/<action>]', [
'presenter' => 'Default',
'action' => 'default',
null => self::useTranslateFilter($domainList, $routerMapping['default']),
]);

return $router;
}

public static function createFykosRouter(?array $domainList, array $routerMapping): Router
{
$router = new RouteList();

$specialRouterMapping = [
'results' => [
'cs' => 'poradi',
'en' => 'results'
]
];


Debugger::barDump($domainList);


foreach ($specialRouterMapping['results'] as $lang => $translated) {
$router->withModule('Default')->addRoute("//<domain>/$translated/<year ([0-9]{2})(-.*)?>", [
'presenter' => 'Results',
'action' => 'default',
null => self::useTranslateFilter($domainList, $routerMapping['default']),
]);
}
$router->withModule('Default')->addRoute("//<domain>/results[/<year [0-9]{2}>]", [
'presenter' => 'Results',
'action' => 'default',
'lang' => 'cs'
// 'lang' => ['filterTable' => [
// 'poradi' => "cs",
// 'results' => "en",
// ]]
]);

$router->withModule('Default')
->addRoute('//<domain>/problems/<year ([0-9]{2})(-.*)?>/<series ([0-9]{1})(-.*)?>', [
Expand All @@ -221,12 +209,13 @@ public static function createFykosRouter(?array $domainList, array $routerMappin
null => self::useTranslateFilter($domainList, $routerMapping['events']),
]);

$router->withModule('Default')
->addRoute('//<domain>/<presenter>[/<action>]', [
'presenter' => 'Default',
'action' => 'default',
null => self::useTranslateFilter($domainList, $routerMapping['default']),
]);
// $router->withModule('Default')
// ->addRoute('//<domain>/<presenter>[/<action>]', [
// 'presenter' => 'Default',
// 'action' => 'default',
// null => self::useTranslateFilter($domainList, $routerMapping['default']),
// ]);


return $router;
}
Expand Down
1 change: 0 additions & 1 deletion app/config/fykos-router-mapping.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ parameters:
Historie: History
Kontakt: Contact
Zadani: Problems
Poradi: Results
ArchivUloh: ProblemsArchive
events:
cs:
Expand Down

0 comments on commit 356a4d9

Please sign in to comment.