20) { Log::fatal('Config::replace_variables(%s): max iteration reached'); return $value; } $value = str_replace($m[0], self :: get($m[1], '', 'string'), $value); $iteration++; } } return $value; } /** * Get list of keys of a specific configuration variable * * @param string $key The configuration variable key * * @return array An array of the keys of a specific configuration variable **/ public static function keys($key) { $value = self :: get($key); return (is_array($value)?array_keys($value):array()); } /** * Set a configuration variable * * @param string $key The configuration variable key * @param mixed $value The configuration variable value * @param array|null &$config Optional configuration to use instead of current loaded configuration * * @return boolean **/ public static function set($key, $value, &$config=null) { $exploded_key = explode('.', $key); if (!is_array($exploded_key)) return false; if (is_array($config)) { $parent = &$config; } else { if (!is_array(self :: $config)) self :: $config = array(); $parent = &self :: $config; } for ($i=0; $i < count($exploded_key) - 1; $i++) { $k = $exploded_key[$i]; if (!array_key_exists($k, $config)) $config[$k] = array(); $config = &$config[$k]; } $config[array_pop($exploded_key)] = $value; return true; } } # vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab