当前位置: 首页>>代码示例>>PHP>>正文


PHP ViewEvent::setResponse方法代码示例

本文整理汇总了PHP中Zend\View\ViewEvent::setResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewEvent::setResponse方法的具体用法?PHP ViewEvent::setResponse怎么用?PHP ViewEvent::setResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\View\ViewEvent的用法示例。


在下文中一共展示了ViewEvent::setResponse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $this->response = new Response();
     $this->event = new ViewEvent();
     $this->event->setResponse($this->response);
     $this->renderer = new HalJsonRenderer(new ApiProblemRenderer());
     $this->strategy = new HalJsonStrategy($this->renderer);
 }
开发者ID:zfcampus,项目名称:zf-hal,代码行数:8,代码来源:HalJsonStrategyTest.php

示例2: 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

示例3: testResponseContentSetToResultIfNotEmpty

 public function testResponseContentSetToResultIfNotEmpty()
 {
     $this->renderer->placeholder('article')->set('Article Content');
     $this->renderer->placeholder('content')->set('Content');
     $event = new ViewEvent();
     $event->setResponse($this->response)->setRenderer($this->renderer)->setResult('Result Content');
     $this->strategy->injectResponse($event);
     $content = $this->response->getContent();
     $this->assertEquals('Result Content', $content);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:10,代码来源:PhpRendererStrategyTest.php

示例4: 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

示例5: 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

示例6: getEvent

 /**
  * Create and return ViewEvent used by render()
  *
  * @return ViewEvent
  */
 protected function getEvent()
 {
     $event = new ViewEvent();
     $event->setTarget($this);
     if (null !== ($request = $this->getRequest())) {
         $event->setRequest($request);
     }
     if (null !== ($response = $this->getResponse())) {
         $event->setResponse($response);
     }
     return $event;
 }
开发者ID:jbmchd,项目名称:semente.lanches,代码行数:17,代码来源:View.php

示例7: testProcessRcmResponses

 /**
  * Test Process Rcm Responses
  *
  * @return void
  *
  * @covers \Rcm\EventListener\ViewEventListener::processRcmResponses
  */
 public function testProcessRcmResponses()
 {
     $event = new ViewEvent();
     $response = new Response();
     $response->setStatusCode(404);
     $mockResponseHandler = $this->getMockBuilder('Rcm\\Service\\ResponseHandler')->disableOriginalConstructor()->getMock();
     $mockResponseHandler->expects($this->once())->method('processResponse');
     $event->setResponse($response);
     /** @var \Rcm\Service\ResponseHandler $mockResponseHandler */
     $listener = new ViewEventListener($mockResponseHandler);
     $listener->processRcmResponses($event);
 }
开发者ID:reliv,项目名称:rcm,代码行数:19,代码来源:ViewEventListenerTest.php

示例8: getPluginViewData

 /**
  * Get a plugin instance rendered view.
  *
  * @param string  $pluginName           Plugin name
  * @param integer $pluginInstanceId     Plugin Instance Id
  * @param array   $pluginInstanceConfig Plugin Instance Config
  *
  * @return array
  * @throws \Rcm\Exception\InvalidPluginException
  * @throws \Rcm\Exception\PluginReturnedResponseException
  */
 public function getPluginViewData($pluginName, $pluginInstanceId, $pluginInstanceConfig)
 {
     /** @var \Rcm\Plugin\PluginInterface $controller */
     $controller = $this->getPluginController($pluginName);
     if (!is_a($controller, '\\Rcm\\Plugin\\PluginInterface')) {
         throw new InvalidPluginException('Plugin ' . $controller . ' must implement the PluginInterface');
     }
     $controller->setRequest($this->request);
     $response = new Response();
     $controller->setResponse($response);
     /** @var \Zend\Mvc\MvcEvent $event */
     $event = $controller->getEvent();
     $event->setRequest($this->request);
     $event->setResponse($response);
     $controller->setEvent($event);
     $viewModel = $controller->renderInstance($pluginInstanceId, $pluginInstanceConfig);
     if ($viewModel instanceof ResponseInterface) {
         $event = new ViewEvent();
         $event->setResponse($viewModel);
         $this->eventManager->trigger(ViewEvent::EVENT_RESPONSE, $event);
         return null;
     }
     /** @var \Zend\View\Helper\Headlink $headlink */
     $headlink = $this->renderer->plugin('headlink');
     /** @var \Zend\View\Helper\HeadScript $headScript */
     $headScript = $this->renderer->plugin('headscript');
     $oldContainer = $headlink->getContainer();
     $linkContainer = new Container();
     $headlink->setContainer($linkContainer);
     $oldScriptContainer = $headScript->getContainer();
     $headScriptContainer = new Container();
     $headScript->setContainer($headScriptContainer);
     $html = $this->renderer->render($viewModel);
     $css = $headlink->getContainer()->getArrayCopy();
     $script = $headScript->getContainer()->getArrayCopy();
     $return = ['html' => $html, 'css' => $this->getContainerSrc($css), 'js' => $this->getContainerSrc($script), 'editJs' => '', 'editCss' => '', 'displayName' => '', 'tooltip' => '', 'icon' => '', 'siteWide' => false, 'md5' => '', 'fromCache' => false, 'canCache' => false, 'pluginName' => $pluginName, 'pluginInstanceId' => $pluginInstanceId];
     if (isset($this->config['rcmPlugin'][$pluginName]['display'])) {
         $return['displayName'] = $this->config['rcmPlugin'][$pluginName]['display'];
     }
     if (isset($this->config['rcmPlugin'][$pluginName]['tooltip'])) {
         $return['tooltip'] = $this->config['rcmPlugin'][$pluginName]['tooltip'];
     }
     if (isset($this->config['rcmPlugin'][$pluginName]['icon'])) {
         $return['icon'] = $this->config['rcmPlugin'][$pluginName]['icon'];
     }
     if (isset($this->config['rcmPlugin'][$pluginName]['canCache'])) {
         $return['canCache'] = $this->config['rcmPlugin'][$pluginName]['canCache'];
     }
     $headlink->setContainer($oldContainer);
     $headScript->setContainer($oldScriptContainer);
     return $return;
 }
开发者ID:reliv,项目名称:rcm,代码行数:63,代码来源:PluginManager.php

示例9: createBaseViewEvent

 /**
  * Creates a ViewEvent object with some dependencies already injected
  * @return ViewEvent
  */
 private function createBaseViewEvent()
 {
     $e = new ViewEvent();
     $e->setResponse(new Response());
     return $e;
 }
开发者ID:acelaya,项目名称:zf2-acyaml,代码行数:10,代码来源:YamlStrategyTest.php


注:本文中的Zend\View\ViewEvent::setResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。