if (!is_readable($file)) continue;
- if (preg_match('/\.(yaml|yml)$/i',$file) and ($yaml = yaml_parse_file($file))) {
+ if (preg_match('/\.(yaml|yml)$/i',$file) and ($yaml = self::yaml_parse_file($file))) {
$dbs = array_replace_recursive($dbs,$yaml);
} elseif (preg_match('/\.php$/i',$file)) {
*/
public static function object2array($o) { return $array = json_decode(json_encode($o), true); }
- /*
- * Function: yaml_encode
- */
- public static function yaml_encode($row) {
+ private static function yaml_init() {
static $Spyc;
if (empty($Spyc) and !function_exists('yaml_emit')) {
require_once(realpath(dirname(__FILE__).'/Spyc.php'));
function yaml_parse_file($file) { return Spyc::YAMLLoad($file); }
$Spyc = true;
}
+ }
+ public static function yaml_parse_file($file) {
+ self::yaml_init();
+ return yaml_parse_file($file);
+ }
+
+ /*
+ * Function: yaml_encode
+ */
+ public static function yaml_encode($row) {
+ self::yaml_init();
$yaml = yaml_emit($row);
$yaml = preg_replace('/^---\s*/','',$yaml);
$yaml = preg_replace('/\n\.\.\.$/','',$yaml);