1 | <?php |
||
22 | abstract class ExchangeBase |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * "multisingleton" |
||
27 | * @var array |
||
28 | */ |
||
29 | protected static $instances = []; |
||
30 | |||
31 | /** |
||
32 | * |
||
33 | * @var type |
||
34 | */ |
||
35 | protected $db; |
||
36 | |||
37 | /** |
||
38 | * |
||
39 | * @var ExchangeDataLoad |
||
40 | */ |
||
41 | protected $dataLoad; |
||
42 | |||
43 | /** |
||
44 | * |
||
45 | * @var SimpleXMLElement |
||
46 | */ |
||
47 | protected $importData; |
||
48 | |||
49 | /** |
||
50 | * Current locale |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $locale; |
||
54 | |||
55 | /** |
||
56 | * |
||
57 | * @var SimpleXMLElement |
||
58 | */ |
||
59 | protected $xml; |
||
60 | |||
61 | /** |
||
62 | * Storing results about queries |
||
63 | * @var array |
||
64 | */ |
||
65 | public static $stats = []; |
||
66 | |||
67 | private function __construct() { |
||
74 | |||
75 | private function __clone() { |
||
78 | |||
79 | /** |
||
80 | * |
||
81 | * @return Properties|Products |
||
82 | */ |
||
83 | public static function getInstance() { |
||
91 | |||
92 | public function __get($name) { |
||
96 | |||
97 | /** |
||
98 | * Alias for CI insert_batch |
||
99 | * @param string $tableName |
||
100 | * @param array $data |
||
101 | * @throws Exception |
||
102 | */ |
||
103 | protected function insertBatch($tableName, $data) { |
||
125 | |||
126 | /** |
||
127 | * Alias for CI insert_batch |
||
128 | * @param string $tableName |
||
129 | * @param array $data |
||
130 | * @throws Exception |
||
131 | * @return bool|void |
||
132 | */ |
||
133 | protected function insertPropertiesData($tableName, $data) { |
||
189 | |||
190 | public function setXml(SimpleXMLElement $xml) { |
||
194 | |||
195 | /** |
||
196 | * Alias for CI update_batch |
||
197 | * @param string $tableName |
||
198 | * @param array $data |
||
199 | * @param string $keyToCompare |
||
200 | * @throws \Exception |
||
201 | */ |
||
202 | protected function updateBatch($tableName, array $data, $keyToCompare) { |
||
222 | |||
223 | /** |
||
224 | * |
||
225 | * @param string $tableName |
||
226 | * @param array $data |
||
227 | * @param string $keyToComare |
||
228 | * @throws Exception |
||
229 | */ |
||
230 | public function _updateBatchGroup($tableName, array $data, $keyToComare) { |
||
240 | |||
241 | /** |
||
242 | * |
||
243 | * @param string $tableName |
||
244 | * @param array $data |
||
245 | * @param string $keyToCompare |
||
246 | * @throws Exception |
||
247 | */ |
||
248 | public function _updatePerOne($tableName, array $data, $keyToCompare) { |
||
265 | |||
266 | /** |
||
267 | * Return statistic |
||
268 | * @return array |
||
269 | */ |
||
270 | public function getStats() { |
||
274 | |||
275 | /** |
||
276 | * Sets the data for import, starts import |
||
277 | * @param SimpleXMLElement $importData |
||
278 | */ |
||
279 | public function import(SimpleXMLElement $importData) { |
||
288 | |||
289 | /** |
||
290 | * Runs the import process |
||
291 | */ |
||
292 | abstract protected function import_(); |
||
293 | |||
294 | } |