Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
response.php
1<?
2
4
6
7abstract class Response extends Result
8{
9 const TYPE_CODE = '';
10
11 protected $id;
12 protected $type;
13 protected $adapter;
14 protected $responseText;
15
16 /* @var Request|null */
17 protected $request;
18
19 protected $result;
20 protected $fetchIterator = 0;
21
22 public function __construct()
23 {
24 parent::__construct();
25 $this->type = static::TYPE_CODE;
26 }
27
28 public function setId($id)
29 {
30 $this->id = $id;
31 }
32
33 public function getId()
34 {
35 return $this->id;
36 }
37
38 public function setData(array $data)
39 {
40 parent::setData($data);
41 $this->fetchIterator = 0;
42 }
43
44 public function setResponseText($responseText)
45 {
46 $this->responseText = $responseText;
47 }
48
49 public function getResponseText()
50 {
51 return $this->responseText;
52 }
53
54 public function fetch()
55 {
56 if(is_array($this->data) && !isset($this->data[0]))
57 {
58 if ($this->fetchIterator == 0)
59 {
60 $row = $this->data;
61 $this->fetchIterator++;
62 }
63 else
64 {
65 return null;
66 }
67 }
68 else if(is_array($this->data) && isset($this->data[$this->fetchIterator]))
69 {
70 $row = $this->data[$this->fetchIterator];
71 $this->fetchIterator++;
72 }
73 else
74 {
75 return null;
76 }
77
78 if (is_array($row))
79 {
80 $result = array();
81 foreach ($row as $k => $v)
82 {
83 $result[mb_strtoupper($k)] = $v;
84 }
85
86 return $result;
87 }
88 else
89 {
90 return $row;
91 }
92 }
93
94 public function getRequest()
95 {
96 return $this->request;
97 }
98
99 public function setRequest(Request $request)
100 {
101 return $this->request = $request;
102 }
103
108 public static function create($type)
109 {
110 return Factory::create(get_called_class(), $type);
111 }
112
113 abstract public function parse($data);
114}
setRequest(Request $request)
Definition response.php:99