Exemplo n.º 1
0
 /**
  * Save comment module configuration
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function saveConfiguration()
 {
     if (null !== ($response = $this->checkAuth([AdminResources::MODULE], ['comment'], AccessManager::UPDATE))) {
         return $response;
     }
     $form = new \Comment\Form\ConfigurationForm($this->getRequest());
     $message = "";
     $response = null;
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         ConfigQuery::write('comment_activated', $data['activated'] ? '1' : '0');
         ConfigQuery::write('comment_moderate', $data['moderate'] ? '1' : '0');
         ConfigQuery::write('comment_ref_allowed', $data['ref_allowed']);
         ConfigQuery::write('comment_only_customer', $data['only_customer'] ? '1' : '0');
         ConfigQuery::write('comment_only_verified', $data['only_verified'] ? '1' : '0');
         ConfigQuery::write('comment_request_customer_ttl', $data['request_customer_ttl']);
         ConfigQuery::write('comment_notify_admin_new_comment', $data['notify_admin_new_comment']);
     } catch (\Exception $e) {
         $message = $e->getMessage();
     }
     if ($message) {
         $form->setErrorMessage($message);
         $this->getParserContext()->addForm($form);
         $this->getParserContext()->setGeneralError($message);
         return $this->render("module-configure", ["module_code" => Comment::getModuleCode()]);
     }
     return RedirectResponse::create(URL::getInstance()->absoluteUrl("/admin/module/" . Comment::getModuleCode()));
 }