Пример #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->setProductionMode(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();
 }
Пример #2
0
 /**
  * Loads configuration from file and process it.
  *
  * @param string $class
  * @return Container
  */
 public function createContainer($class = NULL)
 {
     // add config files
     foreach ($this->getConfigFiles() as $file) {
         if (!file_exists($file)) {
             umask(00);
             @touch($file);
         }
         $this->addConfig($file, self::NONE);
     }
     // create container
     $container = parent::createContainer();
     // register robotLoader and configurator
     if ($this->robotLoader) {
         $container->addService('robotLoader', $this->robotLoader);
     }
     $container->addService('configurator', $this);
     return $container;
 }
Пример #3
0
 /**
  * This method is meant to be overridden, for you to configure your application
  *
  * @return \SystemContainer|\Nette\DI\Container
  */
 protected function createContainer()
 {
     $configurator = new Nette\Config\Configurator();
     $configurator->setTempDirectory(TEMP_DIR);
     return $configurator->createContainer();
 }
Пример #4
0
<?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();