[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/config/ -> sfConfig.class.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the symfony package.
   5   * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
   6   * 
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  /**
  12   * sfConfig stores all configuration information for a symfony application.
  13   *
  14   * @package    symfony
  15   * @subpackage config
  16   * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  17   * @version    SVN: $Id: sfConfig.class.php 3203 2007-01-09 18:32:54Z fabien $
  18   */
  19  class sfConfig
  20  {
  21    protected static
  22      $config = array();
  23  
  24    /**
  25     * Retrieves a config parameter.
  26     *
  27     * @param string A config parameter name
  28     * @param mixed  A default config parameter value
  29     *
  30     * @return mixed A config parameter value, if the config parameter exists, otherwise null
  31     */
  32    public static function get($name, $default = null)
  33    {
  34      return isset(self::$config[$name]) ? self::$config[$name] : $default;
  35    }
  36  
  37    /**
  38     * Indicates whether or not a config parameter exists.
  39     *
  40     * @param string A config parameter name
  41     *
  42     * @return bool true, if the config parameter exists, otherwise false
  43     */
  44    public static function has($name)
  45    {
  46      return array_key_exists($name, self::$config);
  47    }
  48  
  49    /**
  50     * Sets a config parameter.
  51     *
  52     * If a config parameter with the name already exists the value will be overridden.
  53     *
  54     * @param string A config parameter name
  55     * @param mixed  A config parameter value
  56     */
  57    public static function set($name, $value)
  58    {
  59      self::$config[$name] = $value;
  60    }
  61  
  62    /**
  63     * Sets an array of config parameters.
  64     *
  65     * If an existing config parameter name matches any of the keys in the supplied
  66     * array, the associated value will be overridden.
  67     *
  68     * @param array An associative array of config parameters and their associated values
  69     */
  70    public static function add($parameters = array())
  71    {
  72      self::$config = array_merge(self::$config, $parameters);
  73    }
  74  
  75    /**
  76     * Retrieves all configuration parameters.
  77     *
  78     * @return array An associative array of configuration parameters.
  79     */
  80    public static function getAll()
  81    {
  82      return self::$config;
  83    }
  84  
  85    /**
  86     * Clears all current config parameters.
  87     */
  88    public static function clear()
  89    {
  90      self::$config = null;
  91      self::$config = array();
  92    }
  93  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7