Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
result.php
1
<?php
2
namespace
Bitrix\Sale
;
3
4
use
Bitrix\Main\Entity
;
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\ErrorCollection
;
7
8
class
Result
extends
\Bitrix\Main\ORM\Data\Result
9
{
11
protected
$id
;
12
13
protected
$warnings
= array();
14
16
protected
$isSuccess
=
true
;
17
18
public
function
__construct
()
19
{
20
$this->warnings =
new
ErrorCollection
();
21
parent::__construct();
22
}
23
24
public
function
setId
($id)
25
{
26
$this->
id
=
$id
;
27
}
28
33
public
function
getId
()
34
{
35
return
$this->id;
36
}
37
38
public
function
__destruct
()
39
{
40
//just quietly die in contrast Entity\Result either checked errors or not.
41
}
42
43
public
function
addData
(array $data)
44
{
45
if
(is_array($this->data))
46
{
47
$this->data = $this->data + $data;
48
}
49
else
50
{
51
$this->data = $data;
52
}
53
}
54
55
public
function
get
($offset)
56
{
57
if
(isset($this->data[$offset]) || array_key_exists($offset, $this->data))
58
{
59
return
$this->data[$offset];
60
}
61
62
return
null
;
63
}
64
65
public
function
set
($offset, $value)
66
{
67
if
($offset ===
null
)
68
{
69
$this->data[] = $value;
70
}
71
else
72
{
73
$this->data[$offset] = $value;
74
}
75
}
76
82
public
function
addWarnings(array $errors)
83
{
85
foreach
($errors as $error)
86
{
87
$this->addWarning(
ResultWarning::create
($error));
88
}
89
}
90
96
public
function
addWarning
(
Error
$error)
97
{
98
$this->warnings[] = $error;
99
}
100
107
public
function
addError
(
Error
$error)
108
{
109
if
($error instanceof
ResultWarning
)
110
{
111
static::addWarning($error);
112
}
113
else
114
{
115
$this->
isSuccess
=
false
;
116
$this->errors[] = $error;
117
}
118
119
return
$this;
120
}
121
127
public
function
getWarnings
()
128
{
129
return
$this->warnings->toArray();
130
}
131
137
public
function
getWarningMessages
()
138
{
139
$messages = array();
140
141
foreach
($this->
getWarnings
() as $warning)
142
$messages[] = $warning->getMessage();
143
144
return
$messages;
145
}
146
147
151
public
function
hasWarnings
()
152
{
153
return
(count($this->warnings));
154
}
155
156
157
}
158
159
class
ResultError
160
extends
Entity\EntityError
161
{
167
public
static
function
create
(
Error
$error)
168
{
169
return
new
static
($error->
getMessage
(), $error->
getCode
());
170
}
171
}
172
173
class
ResultWarning
174
extends
ResultError
175
{
176
177
}
178
179
class
ResultNotice
180
extends
ResultError
181
{
182
183
}
Bitrix\Main\DB\Result
Definition
result.php:19
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Error\getMessage
getMessage()
Definition
error.php:62
Bitrix\Main\Error\getCode
getCode()
Definition
error.php:53
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\ORM\Data\Result\isSuccess
isSuccess($internalCall=false)
Definition
result.php:52
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Sale\ResultError
Definition
result.php:161
Bitrix\Sale\ResultError\create
static create(Error $error)
Definition
result.php:167
Bitrix\Sale\Result\addError
addError(Error $error)
Definition
result.php:107
Bitrix\Sale\Result\__construct
__construct()
Definition
result.php:18
Bitrix\Sale\Result\getId
getId()
Definition
result.php:33
Bitrix\Sale\Result\$isSuccess
$isSuccess
Definition
result.php:16
Bitrix\Sale\Result\__destruct
__destruct()
Definition
result.php:38
Bitrix\Sale\Result\$warnings
$warnings
Definition
result.php:13
Bitrix\Sale\Result\addData
addData(array $data)
Definition
result.php:43
Bitrix\Sale\Result\addWarning
addWarning(Error $error)
Definition
result.php:96
Bitrix\Sale\Result\setId
setId($id)
Definition
result.php:24
Bitrix\Sale\Result\getWarningMessages
getWarningMessages()
Definition
result.php:137
Bitrix\Sale\Result\getWarnings
getWarnings()
Definition
result.php:127
Bitrix\Sale\Result\hasWarnings
hasWarnings()
Definition
result.php:151
Bitrix\Sale\Result\$id
$id
Definition
result.php:11
Bitrix\Sale\ResultNotice
Definition
result.php:181
Bitrix\Sale\ResultWarning
Definition
result.php:175
Bitrix\Sale
modules
sale
lib
result.php
Создано системой
1.10.0