aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-08-19 17:10:20 -0300
committerSilvio <silvio@devlet.com.br>2010-08-19 17:10:20 -0300
commit5c4d0bf21d6ddf98d3907bff5644263d0eba39bc (patch)
treedc0e72d5248cd66239bda39c86abb78da07642b2
parent2a5cff9990f6e30fa58c4855e41656ea06ff3261 (diff)
downloadcinisis-5c4d0bf21d6ddf98d3907bff5644263d0eba39bc.tar.gz
cinisis-5c4d0bf21d6ddf98d3907bff5644263d0eba39bc.tar.bz2
Supporting multiple YAML libraries
-rw-r--r--classes/Cinisis.php25
-rw-r--r--index.php3
2 files changed, 24 insertions, 4 deletions
diff --git a/classes/Cinisis.php b/classes/Cinisis.php
index 8771b21..915d62f 100644
--- a/classes/Cinisis.php
+++ b/classes/Cinisis.php
@@ -70,7 +70,30 @@ class Cinisis {
}
// Load configuration.
- return Spyc::YAMLLoad($file);
+ return $this->yaml($file);
+ }
+
+ /**
+ * Load YAML into array using backend libraries.
+ *
+ * @param $file
+ * Config file.
+ *
+ * @return
+ * Array with configuration or FALSE if error.
+ */
+ static function yaml($file) {
+ if (file_exists('../contrib/spyc/spyc.php')) {
+ // Use Spyc.
+ include_once '../contrib/spyc/spyc.php';
+ return Spyc::YAMLLoad($file);
+ }
+ elseif (is_callable(array('sfYaml', 'load'))) {
+ // Use symfony built-in yaml loader.
+ return sfYaml::load($file);
+ }
+
+ throw new Exception('No suitable methods for parsing YAML found.');
}
/**
diff --git a/index.php b/index.php
index 612602d..392fa28 100644
--- a/index.php
+++ b/index.php
@@ -3,9 +3,6 @@
* Cinisis - Isis db reading tool.
*/
-// Import Spyc.
-require_once 'contrib/spyc/spyc.php';
-
// Autoloader.
function cinisis_autoload($class) {
if (strstr($class, 'Db')) {