Пример #1
0
	/**
	 * Loads global configuration from file and process it.
	 * @param  string|Nette\Config\Config  file name or Config object
	 * @return \ArrayObject
	 */
	public static function loadConfig($file = NULL)
	{
		return self::$config = self::getConfigurator()->loadConfig($file);
	}
Пример #2
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();
 }
Пример #3
0
	/**
	 * Get initial instance of context.
	 * @return Nette\DI\IContainer
	 */
	public static function getContext()
	{
		if (self::$context === NULL) {
			self::$context = self::getConfigurator()->getContainer();
		}
		return self::$context;
	}
Пример #4
0
 /**
  * Loads global configuration from file and process it.
  * @param  string
  * @param  string
  * @return Nette\Utils\ArrayHash
  */
 public static function loadConfig($file = NULL, $section = NULL)
 {
     if (self::$createdAt) {
         throw new Nette\InvalidStateException('Nette\\Configurator has already been created automatically by Nette\\Environment at ' . self::$createdAt);
     } elseif (!defined('TEMP_DIR')) {
         throw new Nette\InvalidStateException('Nette\\Environment requires constant TEMP_DIR with path to temporary directory.');
     }
     $configurator = new Nette\Configurator();
     $configurator->setDebugMode(!self::isProduction())->setTempDirectory(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']) && $row['file'] !== __FILE__ && is_file($row['file'])) {
             self::$createdAt = "{$row['file']}:{$row['line']}";
             break;
         }
     }
     return self::getConfig();
 }
 /**
  * Determines whether a server is running in production mode.
  *
  * @return bool
  */
 public static function isProduction()
 {
     if (self::$productionMode === null) {
         self::$productionMode = !Nette\Config\Configurator::detectDebugMode();
     }
     return self::$productionMode;
 }