Skip to content

Commit

Permalink
attempt routing
Browse files Browse the repository at this point in the history
  • Loading branch information
vanekm committed Jul 5, 2024
1 parent 0e08d5b commit ab8e4d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
24 changes: 17 additions & 7 deletions app/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Nette\Application\Routers\RouteList;
use Nette\Routing\Route;
use Nette\Routing\Router;
use Tracy\Debugger;

class RouterFactory
{
Expand Down Expand Up @@ -192,20 +193,29 @@ public static function createFykosRouter(?array $domainList, array $routerMappin
{
$router = new RouteList();

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

// Adding dynamic routes based on router mapping configuration
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>/problems/<year ([0-9]{2})(-.*)?>/<series ([0-9]{1})(-.*)?>', [
'presenter' => 'Problems',
'action' => 'default',
null => self::useTranslateFilter($domainList, $routerMapping['default']),
]);

$router->withModule('Default')
->addRoute('//<domain>/results/<year ([0-9]{2})(-.*)?>', [
'presenter' => 'Results',
'action' => 'default',
null => self::useTranslateFilter($domainList, $routerMapping['default']),
]);

$router->addRoute('//<domain>/<module events>/[<presenter>[/<action>]]', [
'presenter' => 'Default',
'action' => 'default',
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 ab8e4d2

Please sign in to comment.