Changeset 8988
- Timestamp:
- 05/15/08 22:24:26 (2 months ago)
- Files:
-
- branches/1.1/lib/yaml/sfYaml.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/yaml/sfYaml.class.php
r8228 r8988 58 58 } 59 59 60 // syck is prefered over sfYamlParser 61 if (function_exists('syck_load')) 60 require_once dirname(__FILE__).'/sfYamlParser.class.php'; 61 62 $yaml = new sfYamlParser(); 63 64 try 62 65 { 63 try 64 { 65 $retval = syck_load($input); 66 } 67 catch (Exception $e) 68 { 69 throw new InvalidArgumentException(sprintf('Syck failed to parse %s, error was: "%s"', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 70 } 66 $ret = $yaml->parse($input); 67 } 68 catch (Exception $e) 69 { 70 throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 71 } 71 72 72 return is_array($retval) ? $retval : array(); 73 } 74 else 75 { 76 require_once dirname(__FILE__).'/sfYamlParser.class.php'; 77 $yaml = new sfYamlParser(); 78 79 try 80 { 81 $ret = $yaml->parse($input); 82 } 83 catch (Exception $e) 84 { 85 throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); 86 } 87 88 return $ret; 89 } 73 return $ret; 90 74 } 91 75 … … 102 86 public static function dump($array, $inline = 2) 103 87 { 104 if (function_exists('syck_dump')) 105 { 106 return syck_dump($array); 107 } 108 else 109 { 110 require_once dirname(__FILE__).'/sfYamlDumper.class.php'; 111 $yaml = new sfYamlDumper(); 88 require_once dirname(__FILE__).'/sfYamlDumper.class.php'; 112 89 113 return $yaml->dump($array, $inline); 114 } 90 $yaml = new sfYamlDumper(); 91 92 return $yaml->dump($array, $inline); 115 93 } 116 94 }