/** * This method is called right after the post is stored in the database during the Form submit. * It checks whether the form has a notification email set, and if so, it sends out a notification * email. * * @param FormSubmitEvent $event */ public function postFormSubmit(FormSubmitEvent $event) { $post = $event->getPost(); $form = $post->getForm(); if (!$form->getNotificationEmail()) { return; } $body = $this->templating->render('OpiferFormBundle:Email:notification.html.twig', ['post' => $post]); $message = \Swift_Message::newInstance()->setSender($this->sender)->setFrom($this->sender)->setTo($form->getNotificationEmail())->setSubject($form->getName())->setBody($body); $this->mailer->send($message); }
/** * This method is called right after the post is stored in the database during the Form submit. * It checks whether the form has a notification email set, and if so, it sends out a notification * email. * * @param FormSubmitEvent $event */ public function postFormSubmit(FormSubmitEvent $event) { $post = $event->getPost(); $form = $post->getForm(); if ($form->getNotificationEmail()) { $this->mailer->sendNotificationMail($form, $post); } if ($form->requiresConfirmation()) { foreach ($post->getValueSet()->getValues() as $value) { if ($value instanceof EmailValue && !empty($value->getValue())) { $this->mailer->sendConfirmationMail($form, $post, $value->getValue()); } } } }
public function postFormSubmit(FormSubmitEvent $event) { $post = $event->getPost(); $values = $post->getValueSet()->getValues(); $this->entityManager->refresh($post); foreach ($values as $value) { if ($value instanceof AttachmentValue) { $media = $this->mediaManager->createMedia(); $media->setFile($value->getFile()); $media->setProvider('file'); $value->setAttachment($media); } } $this->entityManager->persist($post); $this->entityManager->flush(); }
/** * @param FormSubmitEvent $event */ public function postFormSubmit(FormSubmitEvent $event) { $post = $event->getPost(); $values = $post->getValueSet()->getValues(); $this->entityManager->refresh($post); foreach ($values as $value) { if ($value instanceof AttachmentValue) { // Avoid saving the attachment when it's empty and not required if (null === $value->getFile() && !$value->getAttribute()->getRequired()) { continue; } $media = $this->mediaManager->createMedia(); $media->setFile($value->getFile()); $media->setProvider('file'); $value->setAttachment($media); } } $this->entityManager->persist($post); $this->entityManager->flush(); }
/** * This method is called right after the post is stored in the database during the Form submit. * * @param FormSubmitEvent $event */ public function postFormSubmit(FormSubmitEvent $event) { $post = $event->getPost(); $mailinglists = $email = null; foreach ($post->getValueSet()->getValues() as $value) { if ($value instanceof MailingListSubscribeValue && $value->getValue() == true) { $parameters = $value->getAttribute()->getParameters(); if (isset($parameters['mailingLists'])) { $mailinglists = $this->mailingListManager->getRepository()->findByIds($parameters['mailingLists']); } } elseif ($value instanceof EmailValue) { $email = $value->getValue(); } } if ($email && $mailinglists) { foreach ($mailinglists as $mailinglist) { $subscription = new Subscription(); $subscription->setEmail($email); $subscription->setMailingList($mailinglist); $this->subscriptionManager->save($subscription); } } }