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/rospirotorg.ru/bitrix/modules/yandex.market/lib/result/ |
Upload File : |
<?php namespace Yandex\Market\Result; use Yandex\Market; use Bitrix\Main; class Facade { /** * @param Main\Result|Market\Result\Base $result * @param string $exceptionClassName */ public static function handleException($result, $exceptionClassName = Main\SystemException::class) { if (!$result->isSuccess()) { $addErrorMessages = $result->getErrorMessages(); $exceptionMessage = implode(PHP_EOL, $addErrorMessages); throw new $exceptionClassName($exceptionMessage); } } /** * @param Main\Result[]|Market\Result\Base[] $results * * @return Main\Result|Market\Result\Base */ public static function merge(array $results) { /** @var Main\Result|Market\Result\Base $target */ $target = array_shift($results); $targetSupportWarnings = method_exists($target, 'getWarnings'); if ($target === null) { throw new Main\ArgumentException('cant merge empty results'); } foreach ($results as $result) { // errors $errors = $result->getErrors(); if (!empty($errors)) { $target->addErrors($errors); } else if (!$result->isSuccess()) { $target->invalidate(); } // warnings if ($targetSupportWarnings && method_exists($result, 'getWarnings')) { $target->addWarnings($result->getWarnings()); } // data $data = (array)$result->getData(); if (!empty($data)) { $targetData = (array)$target->getData(); $target->setData($targetData + $data); } } return $target; } }