<?php
 namespace Modules\Admin\CurrencyExchange\CheckOnlineSystem; class Controller extends \App\Mvc\Controller\Form\PopupAbstract { protected function initialize() { parent::initialize(); $this->actionsCfg['index'] = [ 'checkSection' => 'Modules/Admin/CurrencyExchange', 'checkOption' => false ]; } protected function getDefaultFormData($R) { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); if (count($CFG['currencies']['markets']) == 1) { $market = $CFG['currencies']['markets'][0]; $formData = []; if ($CFG['currencies']['autoUpdateCurrencyExchange'][$market]) { $formData['stats'] = []; foreach($CFG['currencies']['autoUpdateCurrencyExchange'][$market] as $currencyType => $systemCode) { $formData['stats'][$currencyType]['systemCode'] = $systemCode; $startTime = microtime(true); try { $sysLoaderObj = new \App\CurrencyExchange\System_Load($systemCode); $sysObj = $sysLoaderObj->getSystemObject(); $rates = $sysObj->getRates(); $formData['stats'][$currencyType]['online'] = true; $formData['stats'][$currencyType]['rates'] = $rates; if (!$rates) { $formData['stats'][$currencyType]['error'] = $this->lang['index']['fields']['noRates']; } } catch (\App\CurrencyExchange\Exception $e) { $formData['stats'][$currencyType]['online'] = false; $formData['stats'][$currencyType]['error'] = $e->getMessage(); } $endTime = microtime(true); $formData['stats'][$currencyType]['checkDuration'] = round($endTime-$startTime, 4); } } } return $formData; } protected function processFormData(array $R, \App\MessagesCollector $msgs) { } }