sfSimpleYamlConfigHandler.class.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfSimpleYamlConfigHandler allows you to load simple configuration files formatted as YAML.
  11. *
  12. * @package symfony
  13. * @subpackage config
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfSimpleYamlConfigHandler.class.php 9085 2008-05-20 01:53:23Z Carl.Vondrick $
  16. */
  17. class sfSimpleYamlConfigHandler extends sfYamlConfigHandler
  18. {
  19. /**
  20. * Executes this configuration handler.
  21. *
  22. * @param array $configFiles An array of absolute filesystem path to a configuration file
  23. *
  24. * @return string Data to be written to a cache file
  25. */
  26. public function execute($configFiles)
  27. {
  28. $config = self::getConfiguration($configFiles);
  29. // compile data
  30. $retval = "<?php\n".
  31. "// auto-generated by %s\n".
  32. "// date: %s\nreturn %s;\n";
  33. $retval = sprintf($retval, __CLASS__, date('Y/m/d H:i:s'), var_export($config, true));
  34. return $retval;
  35. }
  36. /**
  37. * @see sfConfigHandler
  38. */
  39. static public function getConfiguration(array $configFiles)
  40. {
  41. return self::parseYamls($configFiles);
  42. }
  43. }