json.php 683 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Fuel\Core;
  3. /**
  4. * JSON Lang file parser
  5. */
  6. class Lang_Json extends \Lang_File
  7. {
  8. protected $ext = '.json';
  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 json_decode($contents, true);
  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. $this->prep_vars($contents);
  29. return \Format::forge()->to_json($contents, true);
  30. }
  31. }