Esempio n. 1
0
 public function canonicalize()
 {
     // override canonization when running PHPUnit tests
     if (!Environment::isConsole()) {
         parent::canonicalize();
     }
 }
Esempio n. 2
0
// 2a) enable Nette\Debug for better exception and error visualisation
Debug::$strictMode = TRUE;
Debug::enable();
// 2b) load configuration from config.ini file
Environment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Environment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new Route('index.php', array('presenter' => 'Homepage', 'action' => 'default'), Route::ONE_WAY);
$router[] = new Route('<presenter>/<id [0-9]+>', array('action' => 'show'));
$router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Homepage', 'action' => 'default', 'id' => NULL));
// Doctrine configuration
$arrayCache = new ArrayCache();
$doctrineConfig = new Configuration();
$doctrineConfig->setMetadataCacheImpl($arrayCache);
$doctrineConfig->setQueryCacheImpl($arrayCache);
$doctrineConfig->setMetadataDriverImpl($doctrineConfig->newDefaultAnnotationDriver(array(APP_DIR . '/models')));
$doctrineConfig->setProxyNamespace('DoctrineProxy');
$doctrineConfig->setProxyDir(TEMP_DIR . '/cache');
//$doctrineConfig->setSQLLogger(Doctrine2Panel::getAndRegister());
$entityManager = EntityManager::create(Environment::getConfig('database')->toArray(), $doctrineConfig);
$application->getContext()->addService('Doctrine\\ORM\\EntityManager', $entityManager);
// Step 5: Run the application!
// Don't run while running PHPUnit tests
if (!Environment::isConsole()) {
    $application->run();
}