Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
error.php
1<?php
2namespace Bitrix\Landing;
3
4class Error
5{
10 protected $errors = array();
11
18 public function addError($code, $message= '')
19 {
20 $this->errors[] = new \Bitrix\Main\Error($message != '' ? $message : $code, $code);
21 }
22
28 public function copyError(\Bitrix\Landing\Error $error)
29 {
30 foreach ($error->getErrors() as $err)
31 {
32 $this->errors[] = $err;
33 }
34 }
35
40 public function getFirstError()
41 {
42 if ($this->errors)
43 {
44 $errors = array_values($this->errors);
45 return array_shift($errors);
46 }
47 return null;
48 }
49
54 public function getErrors()
55 {
56 return $this->errors;
57 }
58
63 public function isEmpty()
64 {
65 return empty($this->errors);
66 }
67
73 public function addFromResult($result)
74 {
75 if (
76 (
77 $result instanceof \Bitrix\Main\Result ||
78 $result instanceof \Bitrix\Main\Entity\AddResult ||
79 $result instanceof \Bitrix\Main\Entity\UpdateResult ||
80 $result instanceof \Bitrix\Main\Entity\DeleteResult
81 ) && !$result->isSuccess()
82 )
83 {
84 foreach ($result->getErrors() as $error)
85 {
86 $this->addError(
87 $error->getCode(),
88 $error->getMessage()
89 );
90 }
91 }
92 }
93}
addFromResult($result)
Definition error.php:73
copyError(\Bitrix\Landing\Error $error)
Definition error.php:28
addError($code, $message='')
Definition error.php:18