コード例 #1
0
ファイル: DoaLinkTest.php プロジェクト: debranova/program
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->doa = new Doa();
     $this->doa->setId(1);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $this->doa->setProgram($program);
     $organisation = new Organisation();
     $organisation->setId(1);
     $organisation->setOrganisation("Organisation");
     $this->doa->setOrganisation($organisation);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->doa)) {
         $this->authorizeService->getAcl()->addResource($this->doa);
         $this->authorizeService->getAcl()->allow([], $this->doa, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Doa())) {
         $this->authorizeService->getAcl()->addResource(new Doa());
     }
     $this->authorizeService->getAcl()->allow([], new Doa(), []);
     $this->doaLink = $this->serviceManager->get('viewhelpermanager')->get('programDoaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
コード例 #2
0
ファイル: DoaController.php プロジェクト: debranova/program
 /**
  * @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;
 }