throwErrorIfServerInvalid(); $this->throwErrorIfExtensionsInvalid(); if ($this->getRequestValue('action') === 'module-settings' && !$this->getRequestValue('loadData') ) { if(empty($this->getRequestValue('magic'))) { return [ "configoption" => [ "Type" => "", "Description" => $this->getJsCode(), ], ]; } if (isset($_REQUEST['magic'])) { $this->cleanOutputBuffer(); return [ProductConfiguration::class, 'index']; } return [ProductConfiguration::class, 'index']; } elseif ($this->getRequestValue('action') === 'save') { $form = new ConfigForm(); $form->runInitContentProcess(); $form->returnAjaxData(); } elseif (($this->getRequestValue('loadData') && $this->getRequestValue('ajax') == '1')) { return [ProductConfiguration::class, 'index']; } }catch (\Exception $e) { //todo log throw new \Exception($e->getMessage()); } } /** * check if server is configured properly * @throws \Exception */ protected function throwErrorIfServerInvalid() { $productId = di('request')->get('id'); $product = Product::where('id', $productId)->first(); if(!$product->servergroup) { throw new \Exception(di('lang')->absoluteT('error', 'invalidServer')); } } /** * check if extension is instlled * @throws \Exception */ protected function throwErrorIfExtensionsInvalid() { $extensions = [ \SoapClient::class => 'soap' ]; foreach($extensions as $class => $extension) { if(!class_exists($class)) { throw new \Exception(di('lang')->addReplacementConstant('extension', $extension)->absoluteT('error', 'extensionRequired')); } } } private function getJsCode() { $params = array_merge($this->request->request->all(), $this->request->query->all()); $dataQuery = http_build_query($params); return " "; } }