/** * Load from file. * * PHP, YAML and JSON formats supported * * @param string $filename * @return bool */ public static function load($filename, $merge = true) { if (file_exists(CONFIGS . $filename)) { $filename = CONFIGS . $filename; } elseif (!file_exists($filename)) { return false; } if (preg_match('/\\.php$/', $filename)) { include $filename; } elseif (preg_match('/\\.yml$/', $filename)) { if (App::import('Vendor', 'Yaml.Spyc')) { $config = SPYC::YAMLload(file_get_contents($filename)); } } elseif (preg_match('/\\.js(on)?$/', $filename)) { $config = json_decode(file_get_contents($filename), true); } else { return; // null } if (isset($config) && is_array($config)) { if ($merge) { self::$_data = self::_merge(self::$_data, $config); self::_refresh(); } return $config; } return true; }