示例#1
0
	/**
	 * Loads global configuration from file and process it.
	 * @param  string
	 * @param  string
	 * @return NArrayHash
	 */
	public static function loadConfig($file = NULL, $section = NULL)
	{
		if (self::$createdAt) {
			throw new InvalidStateException('NConfigurator has already been created automatically by NEnvironment at ' . self::$createdAt);
		}
		$configurator = new NConfigurator;
		$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();
	}