Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
errorcollection.php
1<?php
2
4
5use Bitrix\Main\Entity\Result;
7
9{
15 public function addOne(Error $error)
16 {
17 $this[] = $error;
18 }
19
25 public function addFromResult(Result $result)
26 {
27 $errors = array();
28 foreach ($result->getErrorMessages() as $message)
29 {
30 $errors[] = new Error($message);
31 }
32 unset($message);
33
34 $this->add($errors);
35 }
36
41 public function hasErrors()
42 {
43 return (bool)count($this);
44 }
45
51 public function getErrorsByCode($code)
52 {
53 $needle = array();
54 foreach($this->values as $error)
55 {
57 if($error->getCode() == $code)
58 {
59 $needle[] = $error;
60 }
61 }
62 unset($error);
63
64 return $needle;
65 }
66}