@@ -29,23 +29,10 @@ public function getSchema($resource)
2929 */
3030 public function fillSchema (SimpleXMLElement $ xmlSchema , $ data )
3131 {
32- $ toBeRemoved = array ();
3332 $ resource = $ xmlSchema ->children ()->children ();
34- foreach ($ resource as $ key => $ value ) {
35- if (array_key_exists ($ key , $ data )) {
36- if (property_exists ($ resource ->$ key , 'language ' )) {
37- $ this ->fillLanguageNode ($ resource ->$ key , $ data [$ key ]);
38- } else {
39- $ resource ->$ key = $ data [$ key ];
40- }
41- } else {
42- $ toBeRemoved [] = $ key ;
43- }
44- }
45- foreach ($ toBeRemoved as $ key ) {
46- unset($ resource ->$ key );
33+ foreach ($ data as $ key => $ value ) {
34+ $ this ->processNode ($ resource , $ key , $ value );
4735 }
48-
4936 return $ xmlSchema ;
5037 }
5138
@@ -77,4 +64,22 @@ private function fillLanguageNode($node, $data)
7764 $ node ->language [$ i ] = $ this ->getLanguageValue ($ data , (int )$ node ->language [$ i ]['id ' ]->__toString ());
7865 }
7966 }
67+
68+ /**
69+ * @param SimpleXMLElement $node
70+ * @param $dataKey
71+ * @param $dataValue
72+ */
73+ private function processNode (SimpleXMLElement $ node , $ dataKey , $ dataValue )
74+ {
75+ if (property_exists ($ node ->$ dataKey , 'language ' )) {
76+ $ this ->fillLanguageNode ($ node ->$ dataKey , $ dataValue );
77+ } elseif (is_array ($ dataValue )) {
78+ foreach ($ dataValue as $ key => $ value ) {
79+ $ this ->processNode ($ node ->$ dataKey , $ key , $ value );
80+ }
81+ } else {
82+ $ node ->$ dataKey = $ dataValue ;
83+ }
84+ }
8085}
0 commit comments