*/ class ConfigureController extends BaseAdminController { public function downloadLog() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'mercanet', AccessManager::UPDATE)) { return $response; } $logFilePath = sprintf(THELIA_ROOT."log".DS."%s.log", Mercanet::MODULE_DOMAIN); return Response::create( @file_get_contents($logFilePath), 200, array( 'Content-type' => "text/plain", 'Content-Disposition' => sprintf('Attachment;filename=mercanet-log.txt') ) ); } public function configure() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'mercanet', AccessManager::UPDATE)) { return $response; } $configurationForm = $this->createForm('mercanet_configuration'); $message = null; try { $form = $this->validateForm($configurationForm); // Get the form field values $data = $form->getData(); foreach ($data as $name => $value) { if (is_array($value)) { $value = implode(';', $value); } Mercanet::setConfigValue($name, $value); } $merchantId = $data['merchantId']; // Log configuration modification $this->adminLogAppend( "mercanet.configuration.message", AccessManager::UPDATE, "Mercanet configuration updated" ); // Redirect to the success URL, if ($this->getRequest()->get('save_mode') == 'stay') { // If we have to stay on the same page, redisplay the configuration page/ $url = '/admin/module/Mercanet'; } else { // If we have to close the page, go back to the module back-office page. $url = '/admin/modules'; } return $this->generateRedirect(URL::getInstance()->absoluteUrl($url)); } catch (FormValidationException $ex) { $message = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { $message = $ex->getMessage(); } $this->setupFormErrorContext( $this->getTranslator()->trans("Mercanet configuration", [], Mercanet::MODULE_DOMAIN), $message, $configurationForm, $ex ); return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/Mercanet')); } }