Development

/branches/1.2/lib/config/sfConfig.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/config/sfConfig.class.php

Revision 9085, 2.3 kB (checked in by Carl.Vondrick, 6 years ago)

1.1: fixed @param phpdoc to fit specs in config (refs #2991)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
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$
18  */
19 class sfConfig
20 {
21   protected static
22     $config = array();
23
24   /**
25    * Retrieves a config parameter.
26    *
27    * @param string $name    A config parameter name
28    * @param mixed  $default 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 $name 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 $name  A config parameter name
55    * @param mixed  $value 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 $parameters 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 = array();
91   }
92 }
93
Note: See TracBrowser for help on using the browser.