當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ViewEvent::setRenderer方法代碼示例

本文整理匯總了PHP中Zend\View\ViewEvent::setRenderer方法的典型用法代碼示例。如果您正苦於以下問題:PHP ViewEvent::setRenderer方法的具體用法?PHP ViewEvent::setRenderer怎麽用?PHP ViewEvent::setRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\View\ViewEvent的用法示例。


在下文中一共展示了ViewEvent::setRenderer方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testNonStringResultDoesNotInjectResponse

 public function testNonStringResultDoesNotInjectResponse()
 {
     $this->event->setResponse($this->response);
     $this->event->setRenderer($this->renderer);
     $this->event->setResult($this->response);
     $this->strategy->injectResponse($this->event);
     $this->assertResponseNotInjected();
 }
開發者ID:wizzvet,項目名稱:ZffHtml2pdf,代碼行數:8,代碼來源:Html2PdfStrategyTest.php

示例2: testInjectResponseSetsContentTypeHeaderToApiProblemForApiProblemModel

 /**
  *
  */
 public function testInjectResponseSetsContentTypeHeaderToApiProblemForApiProblemModel()
 {
     $problem = new ApiProblem(500, "Error message");
     $model = new ApiProblemModel($problem);
     $this->event->setModel($model);
     $this->event->setRenderer($this->renderer);
     $this->event->setResult('{"foo":"bar"}');
     $this->strategy->injectResponse($this->event);
     $headers = $this->response->getHeaders();
     $this->assertTrue($headers->has('Content-Type'));
     $header = $headers->get('Content-Type');
     $this->assertEquals('application/problem+json', $header->getFieldValue());
 }
開發者ID:zfcampus,項目名稱:zf-hal,代碼行數:16,代碼來源:HalJsonStrategyTest.php

示例3: testResponseHeadersWithFileName

 public function testResponseHeadersWithFileName()
 {
     $model = new PdfModel();
     $model->setTemplate('basic.phtml');
     $model->setOption('filename', 'testPdfFileName');
     $this->event->setModel($model);
     $this->event->setResponse($this->response);
     $this->event->setRenderer($this->renderer);
     $this->event->setResult($this->renderer->render($model));
     $this->strategy->injectResponse($this->event);
     $headers = $this->event->getResponse()->getHeaders();
     $contentDisposition = $headers->get('Content-Disposition');
     $this->assertInstanceOf('Zend\\Http\\Header\\ContentDisposition', $contentDisposition);
     $this->assertEquals($contentDisposition->getFieldValue(), 'attachment; filename=testPdfFileName.pdf');
     ob_end_flush();
     // Clear out any buffers held by renderers.
 }
開發者ID:raykolbe,項目名稱:DOMPDFModule,代碼行數:17,代碼來源:PdfStrategyTest.php

示例4: testResponseHeadersWithFileName

 public function testResponseHeadersWithFileName()
 {
     $model = $this->serviceManager->get('PdfModel');
     $model->setTemplate('basic.phtml');
     $model->getPdfOptions()->setFilename('testPdfFileName');
     $model->getPdfOptions()->setFooterLines([['text' => 'top line', 'position' => 'center', 'font' => ['family' => 'Helvetica', 'weight' => 'normal', 'size' => 8]], ['text' => 'second line', 'position' => 'left', 'font' => ['family' => 'Helvetica', 'weight' => 'normal', 'size' => 8]], ['text' => 'third line', 'position' => 'right', 'font' => ['family' => 'Helvetica', 'weight' => 'normal', 'size' => 8]]]);
     $model->getPdfOptions()->setHeaderLines([['text' => 'first line', 'position' => 'center', 'font' => ['family' => 'Helvetica', 'weight' => 'normal', 'size' => 8]]]);
     $this->event->setModel($model);
     $this->event->setResponse($this->response);
     $this->event->setRenderer($this->renderer);
     $this->event->setResult($this->renderer->render($model));
     $this->strategy->injectResponse($this->event);
     $headers = $this->event->getResponse()->getHeaders();
     $contentDispositionHeader = $headers->get('Content-Disposition');
     $this->assertInstanceof('Zend\\Http\\Header\\ContentDisposition', $contentDispositionHeader);
     $this->assertEquals($contentDispositionHeader->getFieldValue(), 'attachment; filename=testPdfFileName.pdf');
     ob_end_flush();
 }
開發者ID:uthando-cms,項目名稱:uthando-dompdf,代碼行數:18,代碼來源:PdfStrategyTest.php

示例5: restoreRenderer

 /**
  * Restore the default PhpRenderer, in order to let Zend\View\Strategy\PhpRendererStrategy
  * to trigger his injectResponse()
  *
  * @param ViewEvent $e
  */
 public function restoreRenderer(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer === $this) {
         $e->setRenderer($this->getDefaultPhpRenderer());
     }
 }
開發者ID:nbochenko,項目名稱:cache,代碼行數:13,代碼來源:CacheStrategy.php

示例6: testProcessRcmResponsesWithZendResponseObject

 /**
  * Test Process Rcm Responses with a Zend Http Response.  Method should
  * return early.
  *
  * @return void
  *
  * @covers \Rcm\EventListener\ViewEventListener::processRcmResponses
  */
 public function testProcessRcmResponsesWithZendResponseObject()
 {
     $event = new ViewEvent();
     $response = new ZendHttpResponse();
     $response->setStatusCode(404);
     $mockResponseHandler = $this->getMockBuilder('Rcm\\Service\\ResponseHandler')->disableOriginalConstructor()->getMock();
     $mockResponseHandler->expects($this->never())->method('processResponse');
     $mockContainerPlugin = $this->getMockBuilder('\\Rcm\\View\\Helper\\Container')->disableOriginalConstructor()->getMock();
     $mockContainerPlugin->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $mockRenderer = $this->getMockBuilder('\\Zend\\View\\Renderer\\PhpRenderer')->disableOriginalConstructor()->getMock();
     $mockRenderer->expects($this->any())->method('plugin')->will($this->returnValue($mockContainerPlugin));
     /** @var \Zend\View\Renderer\PhpRenderer $mockRenderer */
     $event->setRenderer($mockRenderer);
     /** @var \Rcm\Service\ResponseHandler $mockResponseHandler */
     $listener = new ViewEventListener($mockResponseHandler);
     $listener->processRcmResponses($event);
 }
開發者ID:reliv,項目名稱:rcm,代碼行數:25,代碼來源:ViewEventListenerTest.php


注:本文中的Zend\View\ViewEvent::setRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。