Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
errorscontainer.php
1
<?php
2
namespace
Bitrix\Sale\Helpers\Order\Builder
;
3
4
use
Bitrix\Main\Error
;
5
use
Bitrix\Sale\Result
;
6
7
final
class
ErrorsContainer
extends
Result
8
{
9
protected
$acceptableErrorCodes
= [];
10
15
public
function
addError
(
Error
$error)
16
{
17
if
(!$this->isErrorAcceptable($error))
18
{
19
parent::addError($error);
20
}
21
}
22
29
public
function
addErrors
(array $errors)
30
{
31
if
(!empty($this->acceptableErrorCodes))
32
{
33
$errorsToAdd = array();
34
35
foreach
($errors as $error)
36
{
37
if
(!$this->isErrorAcceptable($error))
38
{
39
$errorsToAdd[] = $error;
40
}
41
}
42
43
$this->errors->add($errorsToAdd);
44
}
45
else
46
{
47
$this->errors->add($errors);
48
}
49
return
$this;
50
}
51
52
public
function
setAcceptableErrorCodes
(array $errorCodes)
53
{
54
$this->acceptableErrorCodes = $errorCodes;
55
}
56
57
private
function
isErrorAcceptable(
Error
$error)
58
{
59
if
(empty($this->acceptableErrorCodes))
60
{
61
return
false
;
62
}
63
64
$code = $error->
getCode
();
65
66
if
(empty($code))
67
{
68
return
false
;
69
}
70
71
return
in_array($code, $this->acceptableErrorCodes);
72
}
73
}
Bitrix\Main\DB\Result
Definition
result.php:19
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Error\getCode
getCode()
Definition
error.php:53
Bitrix\Sale\Helpers\Order\Builder\ErrorsContainer
Definition
errorscontainer.php:8
Bitrix\Sale\Helpers\Order\Builder\ErrorsContainer\addError
addError(Error $error)
Definition
errorscontainer.php:15
Bitrix\Sale\Helpers\Order\Builder\ErrorsContainer\addErrors
addErrors(array $errors)
Definition
errorscontainer.php:29
Bitrix\Sale\Helpers\Order\Builder\ErrorsContainer\setAcceptableErrorCodes
setAcceptableErrorCodes(array $errorCodes)
Definition
errorscontainer.php:52
Bitrix\Sale\Helpers\Order\Builder\ErrorsContainer\$acceptableErrorCodes
$acceptableErrorCodes
Definition
errorscontainer.php:9
Bitrix\Sale\Helpers\Order\Builder
Definition
basketbuilder.php:2
modules
sale
lib
helpers
order
builder
errorscontainer.php
Создано системой
1.10.0