예제 #1
0
 public function testCanRenderDoa()
 {
     /**
      * Bootstrap the application to have the other information available
      */
     $renderDoa = new RenderDoa();
     $renderDoa->setServiceLocator($this->serviceManager);
     $contact = new Contact();
     $contact->setFirstName('Johan');
     $contact->setLastName('van der Heide');
     $program = new Program();
     $program->setProgram('testProgram');
     $doa = new Doa();
     $doa->setContact($contact);
     $doa->setProgram($program);
     $pdf = $renderDoa->renderForDoa($doa);
     $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf);
     $this->assertTrue(strlen($pdf->getPDFData()) > 0);
 }
예제 #2
0
 /**
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function renderAction()
 {
     $organisationService = $this->getOrganisationService()->setOrganisationId($this->getEvent()->getRouteMatch()->getParam('organisation-id'));
     $program = $this->getProgramService()->findEntityById('Program', $this->getEvent()->getRouteMatch()->getParam('program-id'));
     //Create an empty Doa object
     $programDoa = new Doa();
     $programDoa->setContact($this->zfcUserAuthentication()->getIdentity());
     $programDoa->setOrganisation($organisationService->getOrganisation());
     $programDoa->setProgram($program);
     $renderProjectDoa = $this->renderProgramDoa()->renderForDoa($programDoa);
     $response = $this->getResponse();
     $response->getHeaders()->addHeaderLine('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 36000))->addHeaderLine("Cache-Control: max-age=36000, must-revalidate")->addHeaderLine("Pragma: public")->addHeaderLine('Content-Disposition', 'attachment; filename="' . $programDoa->parseFileName() . '.pdf"')->addHeaderLine('Content-Type: application/pdf')->addHeaderLine('Content-Length', strlen($renderProjectDoa->getPDFData()));
     $response->setContent($renderProjectDoa->getPDFData());
     return $response;
 }