Skip to content
Browse files

added RouterFactory

  • Loading branch information...
1 parent ba77776 commit 2efee7ebfce4b6c278da060d25079da8a78462f0 @dg dg committed
Showing with 27 additions and 6 deletions.
  1. +0 −6 app/bootstrap.php
  2. +2 −0 app/config/config.neon
  3. +25 −0 app/router/RouterFactory.php
View
6 app/bootstrap.php
@@ -3,8 +3,6 @@
/**
* My Application bootstrap file.
*/
-use Nette\Application\Routers\Route;
-
// Load Nette Framework or autoloader generated by Composer
require LIBS_DIR . '/autoload.php';
@@ -29,10 +27,6 @@
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$container = $configurator->createContainer();
-// Setup router
-$container->router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
-$container->router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
-
// Configure and run the application!
$container->application->run();
View
2 app/config/config.neon
@@ -25,6 +25,8 @@ nette:
services:
authenticator: Authenticator
+ routerFactory: RouterFactory
+ router: @routerFactory::createRouter
factories:
View
25 app/router/RouterFactory.php
@@ -0,0 +1,25 @@
+<?php
+
+use Nette\Application\Routers\RouteList,
+ Nette\Application\Routers\Route,
+ Nette\Application\Routers\SimpleRouter;
+
+
+/**
+ * Router factory.
+ */
+class RouterFactory
+{
+
+ /**
+ * @return Nette\Application\IRouter
+ */
+ public function createRouter()
+ {
+ $router = new RouteList();
+ $router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
+ $router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
+ return $router;
+ }
+
+}

0 comments on commit 2efee7e

Please sign in to comment.
Something went wrong with that request. Please try again.