123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /*
- * This file is part of the symfony package.
- * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * sfConfig stores all configuration information for a symfony application.
- *
- * @package symfony
- * @subpackage config
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- * @version SVN: $Id: sfConfig.class.php 9085 2008-05-20 01:53:23Z Carl.Vondrick $
- */
- class sfConfig
- {
- protected static
- $config = array();
- /**
- * Retrieves a config parameter.
- *
- * @param string $name A config parameter name
- * @param mixed $default A default config parameter value
- *
- * @return mixed A config parameter value, if the config parameter exists, otherwise null
- */
- public static function get($name, $default = null)
- {
- return isset(self::$config[$name]) ? self::$config[$name] : $default;
- }
- /**
- * Indicates whether or not a config parameter exists.
- *
- * @param string $name A config parameter name
- *
- * @return bool true, if the config parameter exists, otherwise false
- */
- public static function has($name)
- {
- return array_key_exists($name, self::$config);
- }
- /**
- * Sets a config parameter.
- *
- * If a config parameter with the name already exists the value will be overridden.
- *
- * @param string $name A config parameter name
- * @param mixed $value A config parameter value
- */
- public static function set($name, $value)
- {
- self::$config[$name] = $value;
- }
- /**
- * Sets an array of config parameters.
- *
- * If an existing config parameter name matches any of the keys in the supplied
- * array, the associated value will be overridden.
- *
- * @param array $parameters An associative array of config parameters and their associated values
- */
- public static function add($parameters = array())
- {
- self::$config = array_merge(self::$config, $parameters);
- }
- /**
- * Retrieves all configuration parameters.
- *
- * @return array An associative array of configuration parameters.
- */
- public static function getAll()
- {
- return self::$config;
- }
- /**
- * Clears all current config parameters.
- */
- public static function clear()
- {
- self::$config = array();
- }
- }
|