]> granicus.if.org Git - php/commitdiff
* added optional layer parameter to get() method
authorStig Bakken <ssb@php.net>
Sat, 16 Mar 2002 23:48:23 +0000 (23:48 +0000)
committerStig Bakken <ssb@php.net>
Sat, 16 Mar 2002 23:48:23 +0000 (23:48 +0000)
* added isDefinedLayer() method

pear/PEAR/Config.php

index e8b4b610d81a866359533eb0473f1c213cab9343..1cb4c8eb59ba6457a2604e0c945a5b74241b25e0 100644 (file)
@@ -446,7 +446,7 @@ class PEAR_Config extends PEAR
     }
 
     // }}}
-    // {{{ get(key)
+    // {{{ get(key, [layer])
 
     /**
      * Returns a configuration value, prioritizing layers as per the
@@ -458,12 +458,16 @@ class PEAR_Config extends PEAR
      *
      * @access public
      */
-    function get($key)
+    function get($key, $layer = null)
     {
-        foreach ($this->layers as $layer) {
-            if (isset($this->configuration[$layer][$key])) {
-                return $this->configuration[$layer][$key];
+        if ($layer === null) {
+            foreach ($this->layers as $layer) {
+                if (isset($this->configuration[$layer][$key])) {
+                    return $this->configuration[$layer][$key];
+                }
             }
+        } elseif (isset($this->configuration[$layer][$key])) {
+            return $this->configuration[$layer][$key];
         }
         return null;
     }
@@ -716,6 +720,23 @@ class PEAR_Config extends PEAR
         return false;
     }
 
+    // }}}
+    // {{{ isDefinedLayer(key)
+
+    /**
+     * Tells whether a given config layer exists.
+     *
+     * @param string config layer
+     *
+     * @return bool whether <config layer> exists in this object
+     *
+     * @access public
+     */
+    function isDefinedLayer($layer)
+    {
+        return isset($this->configuration[$layer]);
+    }
+
     // }}}
 }