diff --git a/app/Model/Router/RouterFactory.php b/app/Model/Router/RouterFactory.php index 17c81f7..a7a00a2 100644 --- a/app/Model/Router/RouterFactory.php +++ b/app/Model/Router/RouterFactory.php @@ -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//[/]', '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('/[/]', 'Home:default'); - - return $router; + $this->router[] = $list = new RouteList('Admin'); + $list->addRoute('admin//[/]', 'Home:default'); } - protected function buildMailing(RouteList $router): RouteList + protected function buildFront(): void { - $router[] = $list = new RouteList('Mailing'); - $list[] = new Route('mailing//[/]', 'Home:default'); - - return $router; + $this->router[] = $list = new RouteList('Front'); + $list->addRoute('/[/]', 'Home:default'); } - protected function buildPdf(RouteList $router): RouteList + protected function buildMailing(): void { - $router[] = $list = new RouteList('Pdf'); - $list[] = new Route('pdf//[/]', 'Home:default'); + $this->router[] = $list = new RouteList('Mailing'); + $list->addRoute('mailing//[/]', 'Home:default'); + } - return $router; + protected function buildPdf(): void + { + $this->router[] = $list = new RouteList('Pdf'); + $list->addRoute('pdf//[/]', 'Home:default'); } }