- //Init application
- $application = false;
-
- //Protect application fetching
- try {
- //TODO: handle admin case where we provide a user in extra
- $application = $doctrine->getRepository(Application::class)->findOneBySessionUser($session, $this->getUser());
-
- //Add error message to mail field
- $form->get('slot')->addError(new FormError($trans->trans('Application already exists')));
- //Catch no application cases
- //XXX: combine these catch when php 7.1 is available
- } catch (\Doctrine\ORM\NoResultException $e) {
- //Catch invalid argument because session is not already persisted
- } catch(\Doctrine\ORM\ORMInvalidArgumentException $e) {
- }
-
- //Create new application if none found
- if (!$application) {
- //Create the application
- $application = new Application();
- $application->setSession($session);
- //TODO: handle admin case where we provide a user in extra
- $application->setUser($this->getUser());
- $application->setCreated(new \DateTime('now'));
- $application->setUpdated(new \DateTime('now'));
- $manager->persist($application);
-
- //Flush to get the ids
- $manager->flush();
-
- //Add notice in flash message
- $this->addFlash('notice', $trans->trans('Application request the %date% for %location% on the slot %slot% saved', ['%location%' => $data['location']->getTitle(), '%slot%' => $data['slot']->getTitle(), '%date%' => $data['date']->format('Y-m-d')]));
-
- //Redirect to cleanup the form
- return $this->redirectToRoute('rapsys_air_admin');
- }
+ //Send common headers
+ header('Content-Type: application/pdf');
+
+ //Send remaining headers
+ header('Cache-Control: private, max-age=0, must-revalidate');
+ header('Pragma: public');
+
+ //Send content-length
+ header('Content-Length: '.strlen($output));
+
+ //Display the pdf
+ echo $output;
+
+ //Die for now
+ exit;
+
+# //Create message
+# $message = (new TemplatedEmail())
+# //Set sender
+# ->from(new Address($data['mail'], $data['name']))
+# //Set recipient
+# //XXX: remove the debug set in vendor/symfony/mime/Address.php +46
+# ->to(new Address($this->config['contact']['mail'], $this->config['contact']['title']))
+# //Set subject
+# ->subject($data['subject'])
+#
+# //Set path to twig templates
+# ->htmlTemplate('@RapsysAir/mail/contact.html.twig')
+# ->textTemplate('@RapsysAir/mail/contact.text.twig')
+#
+# //Set context
+# ->context(
+# [
+# 'subject' => $data['subject'],
+# 'message' => strip_tags($data['message']),
+# ]+$this->context
+# );
+#
+# //Try sending message
+# //XXX: mail delivery may silently fail
+# try {
+# //Send message
+# $mailer->send($message);
+#
+# //Redirect on the same route with sent=1 to cleanup form
+# return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params'));
+# //Catch obvious transport exception
+# } catch(TransportExceptionInterface $e) {
+# if ($message = $e->getMessage()) {
+# //Add error message mail unreachable
+# $form->get('mail')->addError(new FormError($this->translator->trans('Unable to contact: %mail%: %message%', ['%mail%' => $this->config['contact']['mail'], '%message%' => $this->translator->trans($message)])));
+# } else {
+# //Add error message mail unreachable
+# $form->get('mail')->addError(new FormError($this->translator->trans('Unable to contact: %mail%', ['%mail%' => $this->config['contact']['mail']])));
+# }
+# }