Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
proxy.php
1<?php
3
4
6
7abstract class Proxy extends Base
8{
12 abstract static protected function getProxy();
13
14 static public function proxyList(array $filter)
15 {
16 $proxy = static::getProxy();
17 $r = $proxy->getList([], $filter);
18 if($r->isSuccess())
19 {
20 $result = $r->getData()['DATA']['result'];
21 }
22 else
23 {
24 $result['error'] = $r->getErrorMessages();
25 }
26 return $result;
27 }
28 static public function proxyAdds(array $list)
29 {
30 $proxy = static::getProxy();
31 $list = static::prepareFieldsAdds($list);
32 $r = $proxy->adds($list);
33 if($r->isSuccess())
34 {
35 /*
36 * [result] => Array()
37 [result_error] => Array
38 (
39 [3] => Array
40 (
41 [error] =>
42 [error_description] => Не введено значение обязательного поля "Имя" или "Фамилия"
43 )
44 )
45 * */
46 $result = $r->getData()['DATA']['result'];
47 }
48 else
49 {
50 $result['error'] = $r->getErrorMessages();
51 }
52 return $result;
53 }
54
55 static protected function prepareFieldsAdds($fields)
56 {
57 $result = [];
58 foreach ($fields as $index=>$item)
59 {
60 $result[$index] = ['fields'=>$item];
61 }
62 return $result;
63 }
64}