Exemple #1
0
 /**
  * Loads global configuration from file and process it.
  * @param  string
  * @param  string
  * @return Nette\ArrayHash
  */
 public static function loadConfig($file = NULL, $section = NULL)
 {
     if (self::$createdAt) {
         throw new Nette\InvalidStateException('Nette\\Config\\Configurator has already been created automatically by Nette\\Environment at ' . self::$createdAt);
     }
     $configurator = new Nette\Config\Configurator();
     $configurator->setDebugMode(!self::isProduction())->setTempDirectory(defined('TEMP_DIR') ? TEMP_DIR : '')->addParameters(array('container' => array('class' => 'EnvironmentContainer')));
     if ($file) {
         $configurator->addConfig($file, $section);
     }
     self::$context = $configurator->createContainer();
     self::$createdAt = '?';
     foreach (debug_backtrace(FALSE) as $row) {
         if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], NETTE_DIR . DIRECTORY_SEPARATOR) !== 0) {
             self::$createdAt = "{$row['file']}:{$row['line']}";
             break;
         }
     }
     return self::getConfig();
 }
<?php

/**
 * Soubor pro načtení všech souborů PHPUnit testů. Používá se jen pro spouštění
 * testů v IDE PHPStorm.
 *
 * @author Martin Štekl <*****@*****.**>
 * @since 2012-07-23
 */
use Nette\Config\Configurator;
define('TEST_DIR', __DIR__);
define('LIBS_DIR', TEST_DIR . '/../vendor');
// Composer autoloading
require LIBS_DIR . '/autoload.php';
// Configure application
$configurator = new Nette\Config\Configurator();
// Enable Nette Debugger for error visualisation & logging
$configurator->setDebugMode(Configurator::AUTO);
$configurator->enableDebugger(TEST_DIR . '/../log', '*****@*****.**');
// Enable RobotLoader - this will load all classes automatically
$configurator->setTempDirectory(TEST_DIR . '/../temp');
$configurator->createRobotLoader()->addDirectory(TEST_DIR)->register();
<?php

use Nette\Config\Configurator;
use Nette\Application\Routers\Route;
use Nette\Application\Routers\SimpleRouter;
require __DIR__ . '/../vendor/nette/nette/Nette/loader.php';
if (is_file($cache = __DIR__ . '/../temp/classes.cache.php')) {
    require $cache;
} else {
    require __DIR__ . '/ClassCacheBuilder.php';
    ClassCacheBuilder::customBuild($cache);
}
$configurator = new Configurator();
$configurator->setDebugMode(FALSE);
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$container = $configurator->createContainer();
$container->router[] = new SimpleRouter('Default:default');
$container->application->run();
Exemple #4
0
getSession($namespace=NULL){return$namespace===NULL?self::getContext()->session:self::getContext()->session->getSection($namespace);}static
function
loadConfig($file=NULL,$section=NULL){if(self::$createdAt){throw
new
Nette\InvalidStateException('Nette\Config\Configurator has already been created automatically by Nette\Environment at '.self::$createdAt);}$configurator=new
Nette\Config\Configurator;$configurator->setDebugMode(!self::isProduction())->setTempDirectory(defined('TEMP_DIR')?TEMP_DIR:'');if($file){$configurator->addConfig($file,$section);}self::$context=$configurator->createContainer();self::$createdAt='?';foreach(debug_backtrace(FALSE)as$row){if(isset($row['file'])&&is_file($row['file'])&&strpos($row['file'],NETTE_DIR.DIRECTORY_SEPARATOR)!==0){self::$createdAt="$row[file]:$row[line]";break;}}return
self::getConfig();}static