1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
errorcollection.php
См. документацию.
1<?php
2
3namespace Bitrix\Forum\Internals\Error;
4
5use Bitrix\Main\ArgumentTypeException;
6use Bitrix\Main\Entity\Result;
7use Bitrix\Main\Type\Dictionary;
8
9final class ErrorCollection extends Dictionary
10{
16 public function __construct(array $values = null)
17 {
18 if($values)
19 {
20 foreach($values as $value)
21 {
22 $this->checkType($value);
23 }
24 }
25 unset($value);
26
27 parent::__construct($values);
28 }
29
35 public function add(array $errors)
36 {
37 foreach ($errors as $error)
38 {
39 $this[] = $error;
40 }
41 unset($error);
42 }
43
49 public function addOne(Error $error)
50 {
51 $this[] = $error;
52 }
53
59 public function addFromResult(Result $result)
60 {
61 $errors = array();
62 foreach ($result->getErrorMessages() as $message)
63 {
64 $errors[] = new Error($message);
65 }
66 unset($message);
67
68 $this->add($errors);
69 }
70
75 public function hasErrors()
76 {
77 return (bool)count($this);
78 }
79
85 public function getErrorsByCode($code)
86 {
87 $needle = array();
88 foreach($this->values as $error)
89 {
91 if($error->getCode() == $code)
92 {
93 $needle[] = $error;
94 }
95 }
96 unset($error);
97
98 return $needle;
99 }
100
106 public function getErrorByCode($code)
107 {
108 foreach($this->values as $error)
109 {
111 if($error->getCode() == $code)
112 {
113 return $error;
114 }
115 }
116 unset($error);
117
118 return null;
119 }
120
128 public function offsetSet($offset, $value)
129 {
130 $this->checkType($value);
131 parent::offsetSet($offset, $value);
132 }
133
138 private function checkType($value)
139 {
140 if(!$value instanceof Error)
141 {
142 throw new ArgumentTypeException('Could not push in ErrorCollection non Error.');
143 }
144 }
145}
__construct(array $values=null)
Определения errorcollection.php:16
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$errors
Определения iblock_catalog_edit.php:74
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
getErrorByCode($code)
Определения errorableimplementation.php:53
$message
Определения payment.php:8
$error
Определения subscription_card_product.php:20