public function processAction() { $form = $this->mailChimpService->getFormFor($this->request->getArgument('list'), $this->request->hasArgument('email_type')); $form->bindRequest($this->request); $this->signalSlotDispatcher->dispatch(__CLASS__, 'onValidateForm', array($form, $this->view, $this)); $success = FALSE; $showForm = TRUE; $message = ''; if ($form->isValid()) { try { $performedAction = $this->mailChimpService->saveForm($form); if ($performedAction == MailChimp::ACTION_SUBSCRIBE) { if ($this->settings['doubleOptIn']) { $message = $this->translate('form_almostSubscribed'); } else { $message = $this->translate('form_subscribed'); } } else { if ($performedAction == MailChimp::ACTION_UPDATE) { $message = $this->translate('form_updated'); } else { $message = $this->translate('form_unsubscribed'); } } $success = TRUE; } catch (InvalidEmail $ex) { $message = $this->translate('exception_invalidEmail'); } catch (ListNotSubscribed $ex) { $message = $this->translate('exception_notSubscribed'); } catch (Error $ex) { $message = $ex->getMessage(); } $showForm = FALSE; } $this->view->assign('form', $form); $this->view->assign('message', $message); $this->view->assign('showForm', $showForm); $this->view->assign('success', $success); $this->view->assign('status', $success ? 'success' : 'error'); return json_encode(array('html' => $this->view->render(), 'success' => $success), JSON_HEX_TAG | JSON_HEX_QUOT); }