public function configure() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('LocalPickup'), AccessManager::UPDATE))) { return $response; } $form = $this->createForm('localpickup.form'); $errmes = null; try { $vform = $this->validateForm($form); $price = $vform->get('price')->getData(); if (preg_match("#^\\d\\.?\\d*\$#", $price)) { $newprice = new LocalPickupShipping(); $newprice->setPrice((double) $price)->save(); } else { $errmes = Translator::getInstance()->trans("price must be a number !"); } return $this->redirectToConfigurationPage(); } catch (\Exception $e) { $errmes = $this->createStandardFormValidationErrorMessage($e); } if (null !== $errmes) { $this->setupFormErrorContext('configuration', $errmes, $form); $response = $this->render("module-configure", ['module_code' => 'LocalPickup']); } return $response; }
public function configure() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('LocalPickup'), AccessManager::UPDATE))) { return $response; } $form = new \LocalPickup\Form\SetDeliveryPrice($this->getRequest()); $errmes = ""; try { $vform = $this->validateForm($form); $price = $vform->get('price')->getData(); if (preg_match("#^\\d\\.?\\d*\$#", $price)) { $newprice = new LocalPickupShipping(); $newprice->setPrice((double) $price)->save(); } else { $errmes = Translator::getInstance()->trans("price must be a number !"); } } catch (\Exception $e) { $errmes = $e->getMessage(); } $this->redirectToRoute("admin.module.configure", array("errmes" => $errmes), array('module_code' => "LocalPickup", '_controller' => 'Thelia\\Controller\\Admin\\ModuleController::configureAction')); }