*/ class GiftOfferedBackController extends BaseAdminController { protected $request; public function updateAction() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, [GiftOffered::DOMAIN_NAME], AccessManager::UPDATE)) { return $response; } $request = $this->getRequest(); // Create the form from the request $form = $this->createForm("giftoffered.configuration.form"); // Initialize the potential exception $ex = null; try { // Check the form against constraints violations $validateForm = $this->validateForm($form); // Get the form field values $data = $validateForm->getData(); ConfigQuery::write('gifts_category', $data['category'], false, true); ConfigQuery::write('gift_amount', $data['amount'], false, true); // Redirect to the configuration page if everything is OK return $this->redirectToConfigurationPage(); } catch (FormValidationException $ex) { // Form cannot be validated. Create the error message using // the BaseAdminController helper method. $error_message = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error $error_message = $ex->getMessage(); } if (null !== $ex) { $this->setupFormErrorContext( 'GiftOffered configuration', $error_message, $form ); $response = $this->render("module-configure", ['module_code' => 'GiftOffered']); } return $response; } /** * Redirect to the configuration page */ protected function redirectToConfigurationPage() { return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/GiftOffered')); } }