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/components/yandex.market/trading.order.view/ |
Upload File : |
<?php namespace Yandex\Market\Components; use Bitrix\Main; use Yandex\Market; if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) { die(); } /** @noinspection PhpUnused */ class TradingOrderViewAjax extends Main\Engine\Controller { public function saveAction($data) { try { $this->loadModule(); $request = $this->emulateRequest([ 'YAMARKET_ORDER' => $data ]); $controller = new Market\Ui\Trading\ShipmentSubmit($request); $response = $controller->processRequest(); $message = $this->combineUiMessage($response); if ($response['status'] !== 'ok') { throw new Main\SystemException($message); } $result = $this->reloadAction(); } catch (Main\SystemException $exception) { $result = null; $this->addError(new Main\Error($exception->getMessage(), $exception->getCode())); } return $result; } public function reloadAction() { global $APPLICATION; $parameters = $this->getUnsignedParameters() + [ 'MODE' => 'RELOAD', ]; return $APPLICATION->IncludeComponent('yandex.market:trading.order.view', 'bitrix24', $parameters); } protected function loadModule() { if (!Main\Loader::includeModule('yandex.market')) { throw new Main\SystemException('Module yandex.market is required'); } } protected function emulateRequest($data) { $server = Main\Application::getInstance()->getContext()->getServer(); return new Main\HttpRequest($server, [], $data, [], []); } protected function combineUiMessage($response) { if (isset($response['message'])) { $result = $response['message']; } else if (isset($response['messages'])) { $messages = array_column($response['messages'], 'text'); $result = implode('<br />', $messages); } else { throw new Main\ArgumentException('unknown ui response format'); } return $result; } }