yml.php 764 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Fuel\Core;
  3. /**
  4. * Yaml Lang file parser
  5. */
  6. class Lang_Yml extends \Lang_File
  7. {
  8. protected $ext = '.yml';
  9. /**
  10. * Loads in the given file and parses it.
  11. *
  12. * @param string $file File to load
  13. * @return array
  14. */
  15. protected function load_file($file)
  16. {
  17. $contents = $this->parse_vars(file_get_contents($file));
  18. return \Format::forge($contents, 'yaml')->to_array();
  19. }
  20. /**
  21. * Returns the formatted language file contents.
  22. *
  23. * @param array $content config array
  24. * @return string formatted config file contents
  25. */
  26. protected function export_format($contents)
  27. {
  28. if ( ! function_exists('spyc_load'))
  29. {
  30. import('spyc/spyc', 'vendor');
  31. }
  32. $this->prep_vars($contents);
  33. return \Spyc::YAMLDump($contents);
  34. }
  35. }