*/ class OpenGraphController extends BaseAdminController { /** * Redirect to the configuration page */ protected function redirectToConfigurationPage() { return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/OpenGraph')); } /** * Fill the form with the configuration data */ public function saveAction() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, [OpenGraph::DOMAIN_NAME], AccessManager::UPDATE)) { return $response; } // Create the form from the request $form = $this->createForm('open.graph.configuration.form'); // Initialize the potential error $error_message = null; try { // Check the form against constraints violations $validateForm = $this->validateForm($form); // Get the form field values $data = $validateForm->getData(); OpenGraph::setConfigValue( OpenGraphConfigValue::ENABLE_SHARING_BUTTONS, is_bool($data["enable_sharing_buttons"]) ? (int) ($data["enable_sharing_buttons"]) : $data["enable_sharing_buttons"] ); foreach ($data as $name => $value) { ConfigQuery::write("opengraph_" . $name, $value, false, true); } // Redirect to the configuration page if everything is OK return $this->redirectToConfigurationPage(); } catch (FormValidationException $e) { // Form cannot be validated. Create the error message using // the BaseAdminController helper method. $error_message = $this->createStandardFormValidationErrorMessage($e); } if (null !== $error_message) { $this->setupFormErrorContext( 'configuration', $error_message, $form ); $response = $this->render("module-configure", ['module_code' => 'OpenGraph']); } return $response; } }