本文整理汇总了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();
}
示例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());
}
示例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.
}
示例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();
}
示例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());
}
}
示例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);
}