Exemplo n.º 1
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handlePostAction(function () use($formData) {
         $this->subscribeFormValidation->validate($formData);
         $bool = $this->subscribeHelper->subscribeToNewsletter($formData['mail'], $formData['salutation'], $formData['first_name'], $formData['last_name']);
         $this->setTemplate($this->get('core.helpers.alerts')->confirmBox($this->translator->t('newsletter', $bool !== false ? 'subscribe_success' : 'subscribe_error'), $this->appPath->getWebRoot()));
     });
 }
Exemplo n.º 2
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handlePostAction(function () use($formData) {
         $ipAddress = $this->request->getSymfonyRequest()->getClientIp();
         $this->formValidation->setIpAddress($ipAddress)->setNewsletterAccess($this->newsletterActive)->validate($formData);
         $formData['date'] = 'now';
         $formData['ip'] = $ipAddress;
         $formData['user_id'] = $this->user->isAuthenticated() ? $this->user->getUserId() : null;
         $formData['active'] = $this->guestbookSettings['notify'] == 2 ? 0 : 1;
         $lastId = $this->guestbookModel->save($formData);
         if ($this->guestbookSettings['notify'] == 1 || $this->guestbookSettings['notify'] == 2) {
             $this->sendNotificationEmail($lastId);
         }
         // Falls es der Benutzer ausgewählt hat, diesen in den Newsletter eintragen
         if ($this->newsletterActive === true && $this->newsletterSubscribeHelper && isset($formData['subscribe_newsletter']) && $formData['subscribe_newsletter'] == 1) {
             $this->newsletterSubscribeHelper->subscribeToNewsletter($formData['mail']);
         }
         return $this->redirectMessages()->setMessage($lastId, $this->translator->t('system', $lastId !== false ? 'create_success' : 'create_error'));
     });
 }