Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
result.php
1<?php
9namespace Bitrix\Main;
10
12
13class Result
14{
16 protected $isSuccess = true;
17
19 protected $errors;
20
22 protected $data = array();
23
24 public function __construct()
25 {
26 $this->errors = new ErrorCollection();
27 }
28
29 public function __clone()
30 {
31 $this->errors = clone $this->errors;
32 }
33
39 public function isSuccess()
40 {
41 return $this->isSuccess;
42 }
43
50 public function addError(Error $error)
51 {
52 $this->isSuccess = false;
53 $this->errors[] = $error;
54 return $this;
55 }
56
62 public function getErrors()
63 {
64 return $this->errors->toArray();
65 }
66
72 public function getErrorCollection()
73 {
74 return $this->errors;
75 }
76
82 public function getErrorMessages()
83 {
84 $messages = array();
85
86 foreach($this->getErrors() as $error)
87 $messages[] = $error->getMessage();
88
89 return $messages;
90 }
91
98 public function addErrors(array $errors)
99 {
100 if ($errors)
101 {
102 $this->isSuccess = false;
103 $this->errors->add($errors);
104 }
105 return $this;
106 }
107
113 public function setData(array $data)
114 {
115 // do not save sql expressions
116 foreach ($data as $k => $v)
117 {
118 if ($v instanceof SqlExpression)
119 {
120 unset($data[$k]);
121 }
122 }
123
124 $this->data = $data;
125
126 return $this;
127 }
128
133 public function getData()
134 {
135 return $this->data;
136 }
137}
addError(Error $error)
Definition result.php:50
addErrors(array $errors)
Definition result.php:98
setData(array $data)
Definition result.php:113