public function saveAction()
 {
     $baseForm = $this->createForm('hooknavigation.configuration');
     $errorMessage = null;
     try {
         $form = $this->validateForm($baseForm);
         $data = $form->getData();
         HookNavigation::setConfigValue(HookNavigationConfigValue::FOOTER_BODY_FOLDER_ID, is_bool($data['footer_body_folder_id']) ? (int) $data['footer_body_folder_id'] : $data['footer_body_folder_id']);
         HookNavigation::setConfigValue(HookNavigationConfigValue::FOOTER_BOTTOM_FOLDER_ID, is_bool($data['footer_bottom_folder_id']) ? (int) $data['footer_bottom_folder_id'] : $data['footer_bottom_folder_id']);
     } catch (FormValidationException $ex) {
         // Invalid data entered
         $errorMessage = $this->createStandardFormValidationErrorMessage($ex);
     } catch (\Exception $ex) {
         // Any other error
         $errorMessage = $this->getTranslator()->trans('Sorry, an error occurred: %err', ['%err' => $ex->getMessage()], [], HookNavigation::MESSAGE_DOMAIN);
     }
     if (null !== $errorMessage) {
         // Mark the form as with error
         $baseForm->setErrorMessage($errorMessage);
         // Send the form and the error to the parser
         $this->getParserContext()->addForm($baseForm)->setGeneralError($errorMessage);
     } else {
         $this->getParserContext()->set('success', true);
     }
     return $this->defaultAction();
 }
Exemple #2
0
 public function onMainFooterBottom(HookRenderEvent $event)
 {
     $bottomConfig = HookNavigation::getConfigValue(HookNavigationConfigValue::FOOTER_BOTTOM_FOLDER_ID);
     $content = $this->render('main-footer-bottom.html', ['bottomFolderId' => $bottomConfig]);
     $event->add($content);
 }