Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
errorcollection.php
1<?php
2
4
5use Bitrix\Main\Entity\Result;
7
13{
19 public function addOne(Error $error)
20 {
21 $this[] = $error;
22 }
23
29 public function addFromResult(Result $result)
30 {
31 $errors = array();
32 foreach ($result->getErrorMessages() as $message)
33 {
34 $errors[] = new Error($message);
35 }
36 unset($message);
37
38 $this->add($errors);
39 }
40
46 public function addFromEntity(IErrorable $entity)
47 {
48 $this->add($entity->getErrors());
49 }
50
55 public function hasErrors()
56 {
57 return (bool)count($this);
58 }
59
65 public function getErrorsByCode($code)
66 {
67 $needle = array();
68 foreach($this->values as $error)
69 {
71 if($error->getCode() === $code)
72 {
73 $needle[] = $error;
74 }
75 }
76 unset($error);
77
78 return $needle;
79 }
80}