php.php 814 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Fuel\Core;
  3. /**
  4. * PHP Config file parser
  5. */
  6. class Config_Php extends \Config_File
  7. {
  8. protected $ext = '.php';
  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. return \Fuel::load($file);
  18. }
  19. /**
  20. * Returns the formatted config file contents.
  21. *
  22. * @param array $content config array
  23. * @return string formatted config file contents
  24. */
  25. protected function export_format($contents)
  26. {
  27. $output = <<<CONF
  28. <?php
  29. CONF;
  30. $output .= 'return '.str_replace(array(' ', 'array (', '\''.APPPATH, '\''.DOCROOT, '\''.COREPATH, '\''.PKGPATH), array("\t", 'array(', 'APPPATH.\'', 'DOCROOT.\'', 'COREPATH.\'', 'PKGPATH.\''), var_export($contents, true)).";\n";
  31. return $output;
  32. }
  33. }