Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
result.php
1<?php
2namespace Bitrix\Sale;
3
7
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
160 extends Entity\EntityError
161{
167 public static function create(Error $error)
168 {
169 return new static($error->getMessage(), $error->getCode());
170 }
171}
172
174 extends ResultError
175{
176
177}
178
180 extends ResultError
181{
182
183}
isSuccess($internalCall=false)
Definition result.php:52
static create(Error $error)
Definition result.php:167
addError(Error $error)
Definition result.php:107
addData(array $data)
Definition result.php:43
addWarning(Error $error)
Definition result.php:96