当前位置: 首页>>代码示例>>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;未经允许,请勿转载。