Example #1
0
 public function contactAction(Request $request, Department $department)
 {
     $contact = new Contact();
     $contactForm = $this->createForm(new ContactType(), $contact, array('action' => $this->generateUrl('admission_contact', array('id' => $department->getId()))));
     // Get the sender email from the parameter file
     $fromEmail = $this->container->getParameter('no_reply_email_contact_form');
     $contactForm->handleRequest($request);
     if ($contactForm->isValid()) {
         //send mail to department
         $message = \Swift_Message::newInstance()->setSubject('Nytt kontaktskjema')->setFrom($fromEmail)->setTo($department->getEmail())->setBody($this->renderView('admission/contactEmail.txt.twig', array('contact' => $contact)));
         $this->get('mailer')->send($message);
         //send receipt mail back to sender
         $receipt = \Swift_Message::newInstance()->setSubject('Kvittering for kontaktskjema')->setFrom($fromEmail)->setTo($contact->getEmail())->setBody($this->renderView('admission/receiptEmail.txt.twig', array('contact' => $contact)));
         $this->get('mailer')->send($receipt);
         //popup text after completion
         $request->getSession()->getFlashBag()->add('contact-notice', 'Kontaktforespørsel sendt, takk for henvendelsen!');
         //redirect to avoid re-posting the form
         return $this->redirect($this->generateUrl('admission_show_specific_department', array('id' => $department->getId())));
     }
     return $this->render('admission/contact.html.twig', array('contactForm' => $contactForm->createView(), 'department' => $department));
 }
Example #2
0
 public function __construct(Department $department, $authenticated)
 {
     $this->departmentId = $department->getId();
     $this->authenticated = $authenticated;
 }