1. sfConfig.class.php
  2. /** * sfConfig stores all configuration information for a symfony application. * * @package symfony * @subpackage config * @author Fabien Potencier * @version SVN: $Id: sfConfig.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ */
  3. class sfConfig
  4. {
  5. protected static
  6. $config = array();
  7. /**
  8. * Retrieves a config parameter.
  9. *
  10. * @param string $name A config parameter name
  11. * @param mixed $default A default config parameter value
  12. *
  13. * @return mixed A config parameter value, if the config parameter exists, otherwise null
  14. */
  15. public static function get($name, $default = null)
  16. {
  17. return isset(self::$config[$name]) ? self::$config[$name] : $default;
  18. }
  19. /**
  20. * Indicates whether or not a config parameter exists.
  21. *
  22. * @param string $name A config parameter name
  23. *
  24. * @return bool true, if the config parameter exists, otherwise false
  25. */
  26. public static function has($name)
  27. {
  28. return array_key_exists($name, self::$config);
  29. }
  30. /**
  31. * Sets a config parameter.
  32. *
  33. * If a config parameter with the name already exists the value will be overridden.
  34. *
  35. * @param string $name A config parameter name
  36. * @param mixed $value A config parameter value
  37. */
  38. public static function set($name, $value)
  39. {
  40. self::$config[$name] = $value;
  41. }
  42. /**
  43. * Sets an array of config parameters.
  44. *
  45. * If an existing config parameter name matches any of the keys in the supplied
  46. * array, the associated value will be overridden.
  47. *
  48. * @param array $parameters An associative array of config parameters and their associated values
  49. */
  50. public static function add($parameters = array())
  51. {
  52. self::$config = array_merge(self::$config, $parameters);
  53. }
  54. /**
  55. * Retrieves all configuration parameters.
  56. *
  57. * @return array An associative array of configuration parameters.
  58. */
  59. public static function getAll()
  60. {
  61. return self::$config;
  62. }
  63. /**
  64. * Clears all current config parameters.
  65. */
  66. public static function clear()
  67. {
  68. self::$config = array();
  69. }
  70. }

Debug toolbar