/** * Loads global configuration from file and process it. * @param string * @param string * @return ArrayHash */ public static function loadConfig($file = NULL, $section = NULL) { if (self::$createdAt) { throw new InvalidStateException('Configurator has already been created automatically by Environment at ' . self::$createdAt); } $configurator = new Configurator(); $configurator->setDebugMode(!self::isProduction())->setTempDirectory(defined('TEMP_DIR') ? TEMP_DIR : ''); if ($file) { $configurator->addConfig($file, $section); } self::$context = $configurator->createContainer(); self::$createdAt = '?'; foreach (PHP_VERSION_ID < 50205 ? debug_backtrace() : 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(); }