Skip to content

Commit

Permalink
Better route management
Browse files Browse the repository at this point in the history
  • Loading branch information
jvitasek authored and f3l1x committed Jul 27, 2023
1 parent b2dc742 commit 4aac584
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions app/Model/Router/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,50 @@

namespace App\Model\Router;

use Nette\Application\Routers\Route;
use Nette\Application\Routers\RouteList;

final class RouterFactory
{

public function create(): RouteList
{
$router = new RouteList();

$this->buildMailing($router);
$this->buildPdf($router);
$this->buildAdmin($router);
$this->buildFront($router);
private RouteList $router;

return $router;
public function __construct()
{
$this->router = new RouteList();
}

protected function buildAdmin(RouteList $router): RouteList
public function create(): RouteList
{
$router[] = $list = new RouteList('Admin');
$list[] = new Route('admin/<presenter>/<action>[/<id>]', 'Home:default');
$this->buildMailing();
$this->buildPdf();
$this->buildAdmin();
$this->buildFront();

return $router;
return $this->router;
}

protected function buildFront(RouteList $router): RouteList
protected function buildAdmin(): void
{
$router[] = $list = new RouteList('Front');
$list[] = new Route('<presenter>/<action>[/<id>]', 'Home:default');

return $router;
$this->router[] = $list = new RouteList('Admin');
$list->addRoute('admin/<presenter>/<action>[/<id>]', 'Home:default');
}

protected function buildMailing(RouteList $router): RouteList
protected function buildFront(): void
{
$router[] = $list = new RouteList('Mailing');
$list[] = new Route('mailing/<presenter>/<action>[/<id>]', 'Home:default');

return $router;
$this->router[] = $list = new RouteList('Front');
$list->addRoute('<presenter>/<action>[/<id>]', 'Home:default');
}

protected function buildPdf(RouteList $router): RouteList
protected function buildMailing(): void
{
$router[] = $list = new RouteList('Pdf');
$list[] = new Route('pdf/<presenter>/<action>[/<id>]', 'Home:default');
$this->router[] = $list = new RouteList('Mailing');
$list->addRoute('mailing/<presenter>/<action>[/<id>]', 'Home:default');
}

return $router;
protected function buildPdf(): void
{
$this->router[] = $list = new RouteList('Pdf');
$list->addRoute('pdf/<presenter>/<action>[/<id>]', 'Home:default');
}

}

0 comments on commit 4aac584

Please sign in to comment.