Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
UpdateServerDataParser.php
1<?php
3
5{
6 private const WRAPER_TAG = "DATA";
7 private string $text;
8
9 public function __construct(string $text)
10 {
11 $this->text = $text;
12 }
13
14 public function parse(): array
15 {
16 $strServerOutput = $this->text;
17 $arRes = [];
18 $strError = '';
19 \CUpdateSystem::ParseServerData($strServerOutput, $arRes, $strError);
20
21 if (!isset($arRes[self::WRAPER_TAG]) || !is_array($arRes[self::WRAPER_TAG]['#']))
22 {
23 return [];
24 }
25
26 $result = [];
27 foreach ($arRes[self::WRAPER_TAG]['#'] as $tag => $items)
28 {
29 $result[$tag] = [];
30 foreach ($items as $item)
31 {
32 $result[$tag] = array_merge($result[$tag], $item['@']);
33 if (isset($item['#']) && !empty($item['#']))
34 {
35 $result[$tag]['_VALUE'] = $item['#'];
36 }
37 }
38 }
39
40 return $result;
41 }
42}