コード例 #1
0
ファイル: PassageController.php プロジェクト: 24eme/aurouze
 /**
  * @Route("/passage/pdf-bon/{id}", name="passage_pdf_bon")
  * @ParamConverter("passage", class="AppBundle:Passage")
  */
 public function pdfBonAction(Request $request, Passage $passage)
 {
     $dm = $this->get('doctrine_mongodb')->getManager();
     $fm = $this->get('facture.manager');
     $html = $this->renderView('passage/pdfBons.html.twig', array('passage' => $passage, 'parameters' => $fm->getParameters()));
     $passage->setImprime(true);
     $dm->flush();
     $filename = sprintf("bon_passage_%s_%s.pdf", $passage->getDateDebut()->format("Y-m-d_H:i"), strtoupper(Transliterator::urlize($passage->getTechniciens()->first()->getIdentite())));
     if ($request->get('output') == 'html') {
         return new Response($html, 200);
     }
     return new Response($this->get('knp_snappy.pdf')->getOutputFromHtml($html, $this->getPdfGenerationOptions()), 200, array('Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $filename . '"'));
 }