Author: Derick Rethans
Date: 2006-01-29 12:45:00 +0100 (Sun, 29 Jan 2006)
New Revision: 2081

Log:
- Document exceptions properly.

Modified:
   packages/Configuration/trunk/src/configuration.php
   packages/Configuration/trunk/src/configuration_manager.php

Modified: packages/Configuration/trunk/src/configuration.php
===================================================================
--- packages/Configuration/trunk/src/configuration.php  2006-01-29 11:40:05 UTC 
(rev 2080)
+++ packages/Configuration/trunk/src/configuration.php  2006-01-29 11:45:00 UTC 
(rev 2081)
@@ -272,6 +272,10 @@
      *
      * @see setting
      *
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not a boolean.
      * @param string $group
@@ -298,6 +302,10 @@
      *
      * @see setting
      *
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not an integer or a float.
      * @param string $group
@@ -324,6 +332,10 @@
      *
      * @see setting
      *
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not a string.
      * @param string $group
@@ -350,6 +362,10 @@
      *
      * @see setting
      *
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not an array.
      * @param string $group
@@ -392,6 +408,11 @@
     /**
      * Removes the setting $setting from the group $group.
      *
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
+     *
      * @param string $group
      * @param string $setting
      * @return void
@@ -632,6 +653,8 @@
     /**
      * Adds a the group $group with the comment $comment the settings.
      *
+     * @throws ezcConfigurationGroupExistsAlreadyException if the group that
+     *         you are trying to add already exists.
      * @param string $group
      * @param string $comment
      * @return void

Modified: packages/Configuration/trunk/src/configuration_manager.php
===================================================================
--- packages/Configuration/trunk/src/configuration_manager.php  2006-01-29 
11:40:05 UTC (rev 2080)
+++ packages/Configuration/trunk/src/configuration_manager.php  2006-01-29 
11:45:00 UTC (rev 2081)
@@ -105,6 +105,10 @@
      * reader. It sets the default location and reader options and which 
reader to
      * use by specifying the class name.
      *
+     * @throws ezcConfigurationInvalidReaderClassException if the $readerClass
+     *         does not exist or does not implement the ezcConfigurationReader
+     *         interface.
+     *
      * @param string $readerClass The name of the class to use as a
      *               configuration reader. This class must implement the
      *               ezcConfigurationReader interface.
@@ -148,24 +152,21 @@
      * new configuration reader based on the settings that were passed to this
      * class with the init() method.
      *
-     * If the $mayFail parameter is set to true, then the function will not try
-     * to call the load() method on the reader if a configuration doesn't
-     * exists (this will throw an ezcConfigurationUnknownConfigException).
-     * If it is not passed, or set to false then load() will always be called,
-     * with the possibility of the exception being thrown.
+     * @throws ezcConfigurationUnknownConfigException if the configuration
+     *         $name does not exist.
      *
      * @param string $name
      * @param bool $mayFail
      * @return ezcConfigurationReader The constructed reader
      */
-    private function fetchReader( $name, $mayFail = false )
+    private function fetchReader( $name )
     {
         if ( !isset( $this->nameMap[$name] ) )
         {
             $className = $this->readerClass;
             $class = new $className();
             $class->init( $this->location, $name, $this->options );
-            if ( $class->configExists() || !$mayFail )
+            if ( $class->configExists() )
             {
                 $class->load();
             }
@@ -180,6 +181,7 @@
      *
      * @throws ezcConfigurationUnknownConfigException if the configuration 
does not
      *         exist.
+     *
      * @param string $name
      * @param string $group
      * @param string $setting
@@ -202,12 +204,23 @@
     /**
      * Returns the configuration object for a the configuration named $name.
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration
+     *         $name does not exist.
+     *
      * @param string $name
      * @return ezcConfiguration
      */
     private function fetchConfig( $name )
     {
-        return $this->fetchReader( $name )->getConfig();
+        $reader = $this->fetchReader( $name );
+        if ( $reader->configExists() )
+        {
+            return $reader->getConfig();
+        }
+        else
+        {
+            throw new ezcConfigurationUnknownConfigException( $name );
+        }
     }
 
     /**
@@ -243,9 +256,15 @@
      * named $name.
      *
      * Uses the fetchSetting() method to fetch the value, this method can throw
-     * exceptions. This method also validates whether the value is actually a
-     * boolean value.
+     * exceptions.
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration does
+     *         not exist.
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
+     *
      * @param string $name
      * @param string $group
      * @param string $setting
@@ -266,6 +285,12 @@
      *
      * @see fetchSetting
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration does
+     *         not exist.
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not a boolean.
      * @param string $name
@@ -288,6 +313,12 @@
      *
      * @see fetchSetting
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration does
+     *         not exist.
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not a number.
      * @param string $name
@@ -310,6 +341,12 @@
      *
      * @see fetchSetting
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration does
+     *         not exist.
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not a string.
      * @param string $name
@@ -332,6 +369,12 @@
      *
      * @see fetchSetting
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration does
+     *         not exist.
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if the setting does not
+     *         exist.
      * @throws ezcConfigurationSettingWrongTypeException if the setting value
      *         is not an array.
      * @param string $name
@@ -380,6 +423,8 @@
      *
      * @see getSettings
      *
+     * @throws ezcConfigurationUnknownConfigException if the configuration does
+     *         not exist.
      * @throws ezcConfigurationUnknownGroupException if the group does not
      *         exist.
      * @throws ezcConfigurationUnknownSettingException if one or more of the
@@ -410,7 +455,7 @@
      */
     public function exists( $name )
     {
-        $reader = $this->fetchReader( $name, true );
+        $reader = $this->fetchReader( $name );
         return $reader->configExists();
     }
 }

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to