[ 'siteTitle' => 'AntCMS', ], 'forceHTTPS' => true, 'activeTheme' => 'Default', 'enableCache' => true, 'admin' => array( 'username' => 'Admin', 'password' => '', ), 'debug' => true, 'baseURL' => $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']), ]; Self::saveConfig($defaultOptions); } /** * Retrieves the current configuration from the AntCMS config file. * * @param string|null $key The key of the configuration item to retrieve. Use dot notation to specify nested keys. * @return mixed The configuration array or a specific value if the key is specified. */ public static function currentConfig(?string $key = null) { $config = AntYaml::parseFile(antConfigFile); if (is_null($key)) { return $config; } else { $keys = explode('.', $key); return self::getArrayValue($config, $keys); } } /** * @param array $array * @param array $keys * @return mixed */ private static function getArrayValue(array $array, array $keys) { foreach ($keys as $key) { if (isset($array[$key])) { $array = $array[$key]; } else { return null; } } return $array; } /** * Saves the AntCMS configuration * * @param array $config The config data to be saved. * @return bool * @throws exception */ public static function saveConfig(array $config) { foreach (self::$ConfigKeys as $defaultKey) { if (!array_key_exists($defaultKey, $config)) { throw new Exception("New config is missing the required {$defaultKey} key from it's array!"); } } return AntYaml::saveFile(antConfigFile, $config); } }