Author: Derick Rethans
Date: 2006-01-28 15:58:20 +0100 (Sat, 28 Jan 2006)
New Revision: 2074

Log:
- Added getSettingsAsList() method to retrieve a group of settings but without
  their names being used as keys in the returned array. This allows the list()
  = $manager->getSettingsAsList( $name, $group, $settingsArray() ); syntax.

Modified:
   packages/Configuration/trunk/ChangeLog
   packages/Configuration/trunk/src/configuration.php
   packages/Configuration/trunk/src/configuration_manager.php
   packages/Configuration/trunk/tests/configuration_manager_test.php

Modified: packages/Configuration/trunk/ChangeLog
===================================================================
--- packages/Configuration/trunk/ChangeLog      2006-01-27 17:53:52 UTC (rev 
2073)
+++ packages/Configuration/trunk/ChangeLog      2006-01-28 14:58:20 UTC (rev 
2074)
@@ -1,3 +1,14 @@
+1.0 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ezcConfigurationManager
+=======================
+
+- Added getSettingsAsList() method to retrieve a group of settings but without
+  their names being used as keys in the returned array. This allows the list()
+  = $manager->getSettingsAsList( $name, $group, $settingsArray() ); syntax.
+       
+
 1.0rc1 - Monday 16 January 2006
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: packages/Configuration/trunk/src/configuration.php
===================================================================
--- packages/Configuration/trunk/src/configuration.php  2006-01-27 17:53:52 UTC 
(rev 2073)
+++ packages/Configuration/trunk/src/configuration.php  2006-01-28 14:58:20 UTC 
(rev 2074)
@@ -430,6 +430,10 @@
     /**
      * Returns the values of the settings $settings in group $group as an 
array.
      *
+     * For each of the setting names passed in the $settings array it will
+     * return the setting in the returned array with the name of the setting as
+     * key.
+     *
      * @throws ezcConfigurationUnknownGroupException if the group does not
      *         exist.
      * @throws ezcConfigurationUnknownSettingException if one or more of the

Modified: packages/Configuration/trunk/src/configuration_manager.php
===================================================================
--- packages/Configuration/trunk/src/configuration_manager.php  2006-01-27 
17:53:52 UTC (rev 2073)
+++ packages/Configuration/trunk/src/configuration_manager.php  2006-01-28 
14:58:20 UTC (rev 2074)
@@ -348,6 +348,12 @@
      * Returns the values of the settings $settings in group $group in the 
configuration
      * named $name.
      *
+     * For each of the setting names passed in the $settings array it will
+     * return the setting in the returned array with the name of the setting as
+     * key.
+     *
+     * @see getSettingsAsList
+     *
      * @throws ezcConfigurationUnknownConfigException if the configuration does
      *         not exist.
      * @throws ezcConfigurationUnknownGroupException if the group does not
@@ -356,16 +362,47 @@
      *         settings do not exist.
      * @param string $name
      * @param string $group
-     * @param string $setting
+     * @param array $settings
      * @return array
      */
-    public function getSettings( $name, $group, $settings )
+    public function getSettings( $name, $group, array $settings )
     {
         $config = $this->fetchConfig( $name );
         return $config->getSettings( $group, $settings );
     }
 
     /**
+     * Returns the values of the settings $settings in group $group as an 
array.
+     *
+     * For each of the setting names passed in the $settings array it will only
+     * return the values of the settings in the returned array, and not include
+     * the name of the setting as the array's key.
+     *
+     * @see getSettings
+     *
+     * @throws ezcConfigurationUnknownGroupException if the group does not
+     *         exist.
+     * @throws ezcConfigurationUnknownSettingException if one or more of the
+     *         settings do not exist.
+     * @param string $name
+     * @param string $group
+     * @param array $settings
+     * @return array
+     */
+    public function getSettingsAsList( $name, $group, array $settings )
+    {
+        $return = array();
+
+        $settings = $this->getSettings( $name, $group, $settings );
+
+        foreach ( $settings as $setting )
+        {
+            $return[] = $setting;
+        }
+        return $return;
+    }
+
+    /**
      * Returns true if the configuration named $name exists.
      *
      * @param string $name

Modified: packages/Configuration/trunk/tests/configuration_manager_test.php
===================================================================
--- packages/Configuration/trunk/tests/configuration_manager_test.php   
2006-01-27 17:53:52 UTC (rev 2073)
+++ packages/Configuration/trunk/tests/configuration_manager_test.php   
2006-01-28 14:58:20 UTC (rev 2074)
@@ -225,6 +225,16 @@
         $this->assertEquals( $expected, $settings );
     }
 
+    public function testSettingsAsList()
+    {
+        $config = ezcConfigurationManager::getInstance();
+        $config->init( 'ezcConfigurationIniReader', 
'Configuration/trunk/tests/files', array() );
+
+        $settings = $config->getSettingsAsList( 'types', 'Types', array( 
'Bool', 'Float', 'Int', 'String', 'Array' ) );
+        $expected = array( true, 3.14, 42, 'Components', array( 1 => 'Een', 2 
=> 'Twee' ) );
+        $this->assertEquals( $expected, $settings );
+    }
+
     public static function suite()
     {
          return new ezcTestSuite( 'ezcConfigurationManagerTest' );

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

Reply via email to