Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
responseyandex.php
1<?
2
4
5use \Bitrix\Main\Error;
6use \Bitrix\Main\Web\Json;
7use \Bitrix\Seo\Retargeting\Response;
8
9
11{
12 const TYPE_CODE = 'yandex';
13
14 protected function getSkippedErrorCodes()
15 {
16 return array(
17 '400' // invalid_parameter: segment data not modified
18 );
19 }
20
21 public function parse($data)
22 {
23 $endpointParts = explode('/', $this->getRequest()->getEndpoint());
24
25 $parsed = is_array($data) ? $data : Json::decode($data);
26
27 if (isset($parsed['errors']))
28 {
29 if (in_array((string) $parsed['code'], $this->getSkippedErrorCodes()))
30 {
31 $this->setData(array());
32 }
33 else
34 {
35 $this->addError(new Error($parsed['message'], $parsed['code']));
36 }
37 }
38
39 if (isset($parsed[$endpointParts[0]]))
40 {
41 $this->setData($parsed[$endpointParts[0]]);
42 }
43 else if(!isset($parsed['errors']))
44 {
45 $this->setData($parsed);
46 }
47 }
48}