sfSecurityConfigHandler.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * sfSecurityConfigHandler allows you to configure action security.
  11. *
  12. * @package symfony
  13. * @subpackage config
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfSecurityConfigHandler.class.php 9085 2008-05-20 01:53:23Z Carl.Vondrick $
  16. */
  17. class sfSecurityConfigHandler 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. * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable
  27. * @throws <b>sfParseException</b> If a requested configuration file is improperly formatted
  28. * @throws <b>sfInitializationException</b> If a view.yml key check fails
  29. */
  30. public function execute($configFiles)
  31. {
  32. // parse the yaml
  33. $config = self::getConfiguration($configFiles);
  34. // compile data
  35. $retval = sprintf("<?php\n".
  36. "// auto-generated by sfSecurityConfigHandler\n".
  37. "// date: %s\n\$this->security = %s;\n",
  38. date('Y/m/d H:i:s'), var_export($config, true));
  39. return $retval;
  40. }
  41. /**
  42. * @see sfConfigHandler
  43. */
  44. static public function getConfiguration(array $configFiles)
  45. {
  46. $config = self::flattenConfiguration(self::parseYamls($configFiles));
  47. // change all of the keys to lowercase
  48. $config = array_change_key_case($config);
  49. return $config;
  50. }
  51. }