File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -339,21 +339,32 @@ protected function _expandRequestShortSyntax($request, SimpleXMLElement $xml)
339339 *
340340 * @param array $array
341341 * @param SimpleXMLElement $xml
342+ * @param string $parentEl
342343 * @return SimpleXMLElement
343344 */
344- protected function _arrayToXml (array $ array , SimpleXMLElement $ xml )
345+ protected function _arrayToXml (array $ array , SimpleXMLElement $ xml, $ parentEl = null )
345346 {
346347 foreach ($ array as $ key => $ value ) {
348+ $ el = is_int ($ key ) && $ parentEl ? $ parentEl : $ key ;
347349 if (is_array ($ value )) {
348- $ this ->_arrayToXml ($ value , $ xml ->addChild ($ key ) );
350+ $ this ->_arrayToXml ($ value , $ this -> _isAssocArray ( $ value ) ? $ xml ->addChild ($ el ) : $ xml , $ el );
349351 } else {
350- $ xml ->addChild ($ key , $ value );
352+ $ xml ->addChild ($ el , $ value );
351353 }
352354 }
353355
354356 return $ xml ;
355357 }
356358
359+ /**
360+ * @param array $array
361+ * @return bool
362+ */
363+ protected function _isAssocArray (array $ array )
364+ {
365+ return $ array && array_keys ($ array ) !== range (0 , count ($ array ) - 1 );
366+ }
367+
357368 /**
358369 * @param string $name
359370 * @return \PleskX\Api\Operator
You can’t perform that action at this time.
0 commit comments