@@ 212-234 (lines=23) @@ | ||
209 | } |
|
210 | } |
|
211 | ||
212 | public function mergeStructure(\SimpleXMLElement $base, \SimpleXMLElement $new) |
|
213 | { |
|
214 | $base->registerXPathNamespace('s', 'http://www.magiumlib.com/Configuration'); |
|
215 | foreach ($new as $item) { |
|
216 | if ($item instanceof \SimpleXMLElement) { |
|
217 | $xpath = sprintf('/*/s:section[@id="%s"]', $item['id']); |
|
218 | $sectionExists = $base->xpath($xpath); |
|
219 | ||
220 | if (!empty($sectionExists) && $sectionExists[0] instanceof \SimpleXMLElement) { |
|
221 | $section = $sectionExists[0]; |
|
222 | } else { |
|
223 | $section = $base->addChild('section'); |
|
224 | } |
|
225 | ||
226 | foreach ($item->attributes() as $name => $value) { |
|
227 | $section[$name] = $value; |
|
228 | } |
|
229 | if ($item->group) { |
|
230 | $this->mergeGroup($section, $item->group); |
|
231 | } |
|
232 | } |
|
233 | } |
|
234 | } |
|
235 | ||
236 | protected function mergeGroup(\SimpleXMLElement $section, \SimpleXMLElement $newGroups) |
|
237 | { |
|
@@ 236-255 (lines=20) @@ | ||
233 | } |
|
234 | } |
|
235 | ||
236 | protected function mergeGroup(\SimpleXMLElement $section, \SimpleXMLElement $newGroups) |
|
237 | { |
|
238 | $section->registerXPathNamespace('s', 'http://www.magiumlib.com/Configuration'); |
|
239 | foreach ($newGroups as $newGroup) { |
|
240 | if ($newGroup instanceof \SimpleXMLElement) { |
|
241 | $xpath = sprintf('./s:group[@id="%s"]', $newGroup['id']); |
|
242 | $groupExists = $section->xpath($xpath); |
|
243 | ||
244 | if (!empty($groupExists) && $groupExists[0] instanceof \SimpleXMLElement) { |
|
245 | $group = $groupExists[0]; |
|
246 | } else { |
|
247 | $group = $section->addChild('group'); |
|
248 | } |
|
249 | foreach ($newGroup->attributes() as $name => $value) { |
|
250 | $group[$name] = $value; |
|
251 | } |
|
252 | $this->mergeElements($group, $newGroup->element); |
|
253 | } |
|
254 | } |
|
255 | } |
|
256 | ||
257 | protected function mergeElements(\SimpleXMLElement $group, \SimpleXMLElement $newElements) |
|
258 | { |