public static function XMLToArray($xml) { $o = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); return UtilArray::ObjectToArray($o); }
public static function getConfig($key = null) { if (!static::$config) { $file = static::getConfigJson(); if (!file_exists($file)) { file_put_contents($file, json_encode(Yaml::parse(static::getConfigYml()))); } static::$config = json_decode(file_get_contents($file), true); static::_bindConfig(self::$config); static::_bindConfig(self::$config); } if (!$key) { return static::$config; } if (array_key_exists($key, static::$config)) { return static::$config[$key]; } if (strpos($key, '.') !== false) { $parts = explode('.', $key, 2); $data = static::getConfig($parts[0]); $data = UtilArray::cascadeGet($data, $parts[1]); if ($data) { return $data; } } throw new Exception("Config '{$key}' not found"); }