Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
batch.php
1<?
9
15class Batch
16{
18 protected $items = [];
19
21 protected $requestId;
22
24 protected $source;
25
27 protected $code;
28
30 protected $externalId;
31
38 public function setLeadItemsArray(array $items)
39 {
40 foreach ($items as $item)
41 {
42 $this->addItem(new LeadItem($item));
43 }
44
45 return $this;
46 }
47
54 public function setArray(array $data)
55 {
56 $this->setRequestId($data['requestId'])
57 ->setLeadItemsArray($data['items'])
58 ->setCode($data['code'])
59 ->setExternalId($data['externalId'])
60 ->setSource($data['source']);
61
62 return $this;
63 }
64
65 public function getArray()
66 {
67 return [
68 'code' => $this->getCode(),
69 'externalId' => $this->getExternalId(),
70 'requestId' => $this->getRequestId(),
71 'items' => array_map(
72 function ($item)
73 {
75 return $item->getData();
76 },
77 $this->getItems()
78 ),
79 'source' => $this->getSource(),
80 ];
81 }
82
88 public function getItems()
89 {
90 return $this->items;
91 }
92
99 public function addItem(Item $item)
100 {
101 $this->items[] = $item;
102 return $this;
103 }
104
110 public function getRequestId()
111 {
112 return $this->requestId;
113 }
114
121 public function setRequestId($requestId)
122 {
123 $this->requestId = $requestId;
124 return $this;
125 }
126
132 public function getSource()
133 {
134 return $this->source;
135 }
136
143 public function setSource($source)
144 {
145 $this->source = $source;
146 return $this;
147 }
148
154 public function getCode()
155 {
156 return $this->code;
157 }
158
165 public function setCode($code)
166 {
167 $this->code = $code;
168 return $this;
169 }
170
176 public function getExternalId()
177 {
178 return $this->externalId;
179 }
180
187 public function setExternalId($externalId)
188 {
189 $this->externalId = $externalId;
190 return $this;
191 }
192}
193
setLeadItemsArray(array $items)
Definition batch.php:38