Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/sale/lib/helpers/order/builder/ |
Upload File : |
<?php namespace Bitrix\Sale\Helpers\Order\Builder; use Bitrix\Main\Error; use Bitrix\Sale\Result; final class ErrorsContainer extends Result { protected $acceptableErrorCodes = []; /** * Adds the error. * @param Error $error */ public function addError(Error $error) { if(!$this->isErrorAcceptable($error)) { parent::addError($error); } } /** * Adds array of Error objects * * @param Error[] $errors * @return $this */ public function addErrors(array $errors) { if(!empty($this->acceptableErrorCodes)) { $errorsToAdd = array(); foreach($errors as $error) { if(!$this->isErrorAcceptable($error)) { $errorsToAdd[] = $error; } } $this->errors->add($errorsToAdd); } else { $this->errors->add($errors); } return $this; } public function setAcceptableErrorCodes(array $errorCodes) { $this->acceptableErrorCodes = $errorCodes; } private function isErrorAcceptable(Error $error) { if(empty($this->acceptableErrorCodes)) { return false; } $code = $error->getCode(); if(empty($code)) { return false; } return in_array($code, $this->acceptableErrorCodes); } }