/** * {@inheritDoc} */ public function preRender(TemplateExtensionInterface $templateExtension, Request $request) { $settings = $templateExtension->getSettings(); }
/** * {@inheritDoc} */ public function preRender(TemplateExtensionInterface $templateExtension, Request $request) { $settings = $templateExtension->getSettings(); $settings['formName'] = isset($settings['formName']) ? $settings['formName'] : 'quote_form'; $settings['variableName'] = isset($settings['variableName']) ? $settings['variableName'] : 'quoteForm'; $settings['successMessage'] = isset($settings['successMessage']) ? $settings['successMessage'] : 'Thank You For Your Submission'; $settings['errorMessage'] = isset($settings['errorMessage']) ? $settings['errorMessage'] : 'Whoops.. looks like something was incorrect'; $settings['successPage'] = isset($settings['successPage']) ? $settings['successPage'] : false; $this->forms[$settings['formName']] = $this->formFactory->create(new QuoteExtensionFormType($settings), new Quote(), array()); if ($request->getMethod() == 'POST') { if ($this->forms[$settings['formName']]->submit($request) && $this->forms[$settings['formName']]->isValid()) { $this->session->getFlashBag()->add('success', $settings['successMessage']); return new RedirectResponse($this->router->generate($settings['successPage'])); } else { $this->session->getFlashBag()->add('error', $settings['errorMessage']); } } }