sfSecurityConfigHandler.class.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. }