Issues

ZF-2285: Allow Zend_Config_Xml to support multiple values of the same name as an array

Description

Support XML config files like:


......

so that the $config representation is:


$subject1 = $config->emailList->{0};
$subject2 = $config->emailList->{1};

Comments

Proposed patch by Simon Mundy:


Zend/Config/Xml.php
===================================================================
--- Xml.php (revision 6921)
+++ Xml.php (working copy)
@@ -137,10 +137,18 @@
         if (count($xmlObject->children())) {
             foreach ($xmlObject->children() as $key => $value) {
                 if ($value->children()) {
-                    $config[$key] = $this->_toArray($value);
+                    $value = $this->_toArray($value);
                 } else {
-                    $config[$key] = (string) $value;
+                    $value = (string) $value;
                 }
+                if (isset($config[$key])) {
+                    if (!is_array($config[$key])) {
+                        $config[$key] = array($config[$key]);
+                    }
+                    $config[$key][] = $value;
+                } else {
+                    $config[$key] = $value;
+                }
             }
         } else  {
             // object has no children: it's a string

Fixed in SVN 7066 (trunk) and 7067 (release-1.0).

Final code is essentially the same as Simon's. Thanks Simon!