Created
November 5, 2012 15:19
-
-
Save tkafka/4017713 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Nette\Diagnostics\Debugger, | |
Nette\Application\Routers\Route, | |
Nette\Application\Routers\RouteList, | |
Nette\Application\Routers\SimpleRouter; | |
// Load Nette Framework | |
require LIBS_DIR . '/Nette/loader.php'; | |
// Configure application | |
$configurator = new Nette\Config\Configurator; | |
Nette\Diagnostics\Debugger::$maxLen = 1000; | |
Nette\Diagnostics\Debugger::$maxDepth = 5; | |
// $configurator->setProductionMode($configurator::AUTO); | |
$configurator->setDebugMode(true); | |
$configurator->enableDebugger(__DIR__ . '/../log'); | |
// Enable RobotLoader - this will load all classes automatically | |
$configurator->setTempDirectory(__DIR__ . '/../temp'); | |
$configurator->createRobotLoader() | |
->addDirectory(APP_DIR) | |
->addDirectory(LIBS_DIR) | |
->register(); | |
$configurator->onCompile[] = function ($configurator, $compiler) { | |
$compiler->addExtension('quotes', new QuotesExtension); | |
}; | |
// Create Dependency Injection container from config.neon file | |
$configurator->addConfig(__DIR__ . '/config/config.neon'); | |
$container = $configurator->createContainer(); | |
// Setup router using mod_rewrite detection | |
if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) { | |
$container->router[] = new Route('index.php', 'Front:Home:default', Route::ONE_WAY); | |
$container->router[] = $adminRouter = new RouteList('Admin'); | |
$adminRouter[] = new Route('admin/<presenter>/<action>', 'Auth:default'); | |
$container->router[] = $frontRouter = new RouteList('Front'); | |
$frontRouter[] = new Route('positions/[<tags .+>]', array( | |
'presenter' => 'positions', | |
'action' => 'default', | |
'tags' => array( | |
Route::VALUE => NULL, | |
Route::FILTER_IN => NULL, | |
Route::FILTER_OUT => NULL, | |
) | |
)); | |
$frontRouter[] = new Route('position/add', array( | |
'presenter' => 'position', | |
'action' => 'add' | |
)); | |
$frontRouter[] = new Route('position/[<name>]-<id [0-9]*>[/<action edit>[/<version>]]', array( | |
'presenter' => 'position', | |
'action' => 'default', | |
'id' => NULL, | |
'version' => NULL, | |
'name' => array( | |
Route::VALUE => NULL, | |
Route::FILTER_IN => function ($url) { | |
return Nette\Utils\Strings::webalize($url); | |
}, | |
Route::FILTER_OUT => function ($url) { | |
return Nette\Utils\Strings::webalize($url); | |
}, | |
) | |
)); | |
$container->router[] = $frontRouter = new RouteList('Front'); | |
$frontRouter[] = new Route('<presenter>/<action>[/<id>]', 'Home:default'); | |
} else { | |
$container->router = new SimpleRouter('Front:Home:default'); | |
} | |
$application = Nette\Environment::getApplication(); | |
$application->onStartup[] = function () use ($container) { | |
Model::init((object)$container->params['database']); | |
}; | |
// Configure and run the application! | |
$container->application->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment