[limb-svn] r6976 - in 3.x/trunk/limb/config: src tests/cases

svn at limb-project.com svn at limb-project.com
Tue Apr 29 16:33:32 MSD 2008


Author: korchasa
Date: 2008-04-29 16:33:32 +0400 (Tue, 29 Apr 2008)
New Revision: 6976
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6976

Modified:
   3.x/trunk/limb/config/src/lmbConf.class.php
   3.x/trunk/limb/config/tests/cases/lmbConfTest.class.php
Log:
-- add configuration file name to lmbNoSuchPropertyException

Modified: 3.x/trunk/limb/config/src/lmbConf.class.php
===================================================================
--- 3.x/trunk/limb/config/src/lmbConf.class.php	2008-04-29 11:58:42 UTC (rev 6975)
+++ 3.x/trunk/limb/config/src/lmbConf.class.php	2008-04-29 12:33:32 UTC (rev 6976)
@@ -1,3 +1,4 @@
+
 <?php
 /*
  * Limb PHP Framework
@@ -7,6 +8,7 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/core/src/lmbObject.class.php');
+lmb_require('limb/core/src/exception/lmbNoSuchPropertyException.class.php');
 
 /**
  * class lmbConf.
@@ -16,14 +18,17 @@
  */
 class lmbConf extends lmbObject
 {
+  protected $_file;
+
   function __construct($file)
   {
     $conf = array();
+    $this->_file = $file;
 
-    if(!include($file))
-      throw new lmbException("Config file '$file' not found");
+    if(!include($this->_file))
+      throw new lmbException("Config file '$this->_file' not found");
 
-    if($override_file = $this->_getOverrideFile($file))
+    if($override_file = $this->_getOverrideFile($this->_file))
     {
       $original = $conf;
       include($override_file);
@@ -42,5 +47,16 @@
     else
       return false;
   }
+
+  function get($name, $default = LIMB_UNDEFINED)
+  {
+    try {
+      return parent::get($name, $default);
+    }
+    catch (lmbNoSuchPropertyException $e)
+    {
+      throw new lmbNoSuchPropertyException('Option ' . $name . ' not found in ' . $this->_file);
+    }
+  }
 }
 

Modified: 3.x/trunk/limb/config/tests/cases/lmbConfTest.class.php
===================================================================
--- 3.x/trunk/limb/config/tests/cases/lmbConfTest.class.php	2008-04-29 11:58:42 UTC (rev 6975)
+++ 3.x/trunk/limb/config/tests/cases/lmbConfTest.class.php	2008-04-29 12:33:32 UTC (rev 6976)
@@ -40,14 +40,12 @@
     $conf = new lmbConf(dirname(__FILE__) . '/conf.php');
 
     try {
-      $a = $conf->get('some_not_existed_option');
+      $conf->get('some_not_existed_option');
       $this->fail();
-    } catch (lmbException $e)
+    }
+    catch (lmbNoSuchPropertyException $e)
     {
       $this->pass();
     }
-
   }
-}
-
-
+}
\ No newline at end of file



More information about the limb-svn mailing list