Skip to content
Browse files

added cassandra.yaml support via Core::loadConfig(); ** deprecates lo…

…adConfigXML();
  • Loading branch information...
1 parent 0a54465 commit 0a147963c21dbbe286a2168583f0fab1bafcef80 @mjpearson committed Jul 20, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 lib/Core.class.php
View
24 lib/Core.class.php
@@ -592,6 +592,30 @@ static public function loadConfigXML() {
return $conf;
}
+ static public function loadConfig() {
+ if (!file_exists(CASSANDRA_CONF_PATH)) {
+ throw new RuntimeException('Cannot build models, file not found ('.CASSANDRA_CONF_PATH.')\n');
+ }
+
+ $tokens = explode('/', CASSANDRA_CONF_PATH);
+ $file = array_pop($tokens);
+
+ list($f, $ext) = explode('.', $file);
+ $ext = strtolower($ext);
+
+ $conf = NULL;
+ if ($ext == 'xml') {
+ $conf = simplexml_load_file(CASSANDRA_CONF_PATH);
+ } elseif ($ext == 'yaml') {
+ if (!function_exists('syck_load')) {
+ throw new RuntimeException('YAML config found but syck module not supported');
+ } else {
+ $conf = syck_load(file_get_contents(CASSANDRA_CONF_PATH));
+ }
+ }
+ return $conf;
+ }
+
/**
* Generates current time, or microtime for 64-bit systems
* @return int timestamp

0 comments on commit 0a14796

Please sign in to comment.
Something went wrong with that request. Please try again.