Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
error.php
1
<?php
2
3
namespace
Bitrix\Translate
;
4
5
use
Bitrix\Main
;
6
10
trait
Error
11
{
13
protected
$errorCollection;
14
22
final
public
function
addError
(Main\
Error
$error): self
23
{
24
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
25
{
26
$this->errorCollection =
new
Main\ErrorCollection
;
27
}
28
29
$this->errorCollection[] = $error;
30
31
return
$this;
32
}
33
41
final
public
function
addErrors
(array $errors): self
42
{
43
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
44
{
45
$this->errorCollection =
new
Main\ErrorCollection
;
46
}
47
48
$this->errorCollection->
add
($errors);
49
50
return
$this;
51
}
52
58
final
public
function
getErrors
(): array
59
{
60
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
61
{
62
return
array();
63
}
64
65
return
$this->errorCollection->toArray();
66
}
67
75
final
public
function
getErrorByCode
($code): ?Main\
Error
76
{
77
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
78
{
79
return
null
;
80
}
81
82
return
$this->errorCollection->getErrorByCode($code);
83
}
84
90
final
public
function
getLastError
(): ?Main\
Error
91
{
92
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
93
{
94
return
null
;
95
}
96
if
(!$this->
hasErrors
())
97
{
98
return
null
;
99
}
100
101
$offset = $this->errorCollection->count() - 1;
102
103
return
$this->errorCollection->offsetGet($offset);
104
}
105
111
final
public
function
getFirstError
(): ?Main\
Error
112
{
113
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
114
{
115
return
null
;
116
}
117
if
(!$this->
hasErrors
())
118
{
119
return
null
;
120
}
121
122
return
$this->errorCollection->offsetGet(0);
123
}
124
130
final
public
function
hasErrors
(): bool
131
{
132
if
(!$this->errorCollection instanceof Main\
ErrorCollection
)
133
{
134
return
false
;
135
}
136
137
return
!$this->errorCollection->isEmpty();
138
}
139
146
final
public
function
hasError
($code): bool
147
{
148
if
(
149
!$this->errorCollection instanceof Main\
ErrorCollection
||
150
$this->errorCollection->
isEmpty
()
151
)
152
{
153
return
false
;
154
}
155
156
$err = $this->errorCollection->getErrorByCode($code);
157
158
return
($err instanceof Main\
Error
);
159
}
160
}
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\ErrorCollection\add
add(array $errors)
Definition
errorcollection.php:32
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Type\Dictionary\isEmpty
isEmpty()
Definition
dictionary.php:206
Bitrix\Main
Bitrix\Main\getErrors
getErrors()
Definition
errorableimplementation.php:34
Bitrix\Main\hasErrors
hasErrors()
Definition
errorableimplementation.php:17
Bitrix\Main\getErrorByCode
getErrorByCode($code)
Definition
errorableimplementation.php:53
Bitrix\Translate
Bitrix\Translate\getLastError
getLastError()
Definition
error.php:90
Bitrix\Translate\getFirstError
getFirstError()
Definition
error.php:111
Bitrix\Translate\addErrors
addErrors(array $errors)
Definition
error.php:41
Bitrix\Translate\addError
addError(Main\Error $error)
Definition
error.php:22
Bitrix\Translate\hasError
hasError($code)
Definition
error.php:146
modules
translate
lib
error.php
Создано системой
1.10.0