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


PHP ViewEvent::setModel方法代码示例

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


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

示例1: testReturnsNullWhenCannotSelectRenderer

 public function testReturnsNullWhenCannotSelectRenderer()
 {
     $model = new ViewModel();
     $request = new HttpRequest();
     $this->event->setModel($model);
     $this->event->setRequest($request);
     $this->assertNull($this->strategy->selectRenderer($this->event));
 }
开发者ID:wizzvet,项目名称:ZffHtml2pdf,代码行数:8,代码来源:Html2PdfStrategyTest.php

示例2: testSelectRendererReturnsJsonRendererWhenSwaggerViewModelIsPresentInEvent

 public function testSelectRendererReturnsJsonRendererWhenSwaggerViewModelIsPresentInEvent()
 {
     $event = new ViewEvent();
     $event->setName(ViewEvent::EVENT_RENDERER);
     $event->setModel(new ViewModel([]));
     $renderer = $this->strategy->selectRenderer($event);
     $this->assertSame($this->renderer, $renderer);
     return $event;
 }
开发者ID:louiselista,项目名称:BlueSystem,代码行数:9,代码来源:SwaggerViewStrategyTest.php

示例3: testSelectRendererWhenTemplateFound

 public function testSelectRendererWhenTemplateFound()
 {
     $model = $this->getMock('Zend\\View\\Model\\ModelInterface');
     $model->expects($this->at(0))->method('getTemplate')->will($this->returnValue('key1'));
     $event = new ViewEvent();
     $event->setModel($model);
     $result = $this->strategy->selectRenderer($event);
     $this->assertSame($this->renderer, $result);
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:9,代码来源:TwigStrategyTest.php

示例4: testSelectRendererWithExtension

 public function testSelectRendererWithExtension()
 {
     $model = $this->getMock('Zend\\View\\Model\\ModelInterface');
     $model->expects($this->at(0))->method('getTemplate')->will($this->returnValue('test.md'));
     $event = new ViewEvent();
     $event->setModel($model);
     $result = $this->strategy->selectRenderer($event);
     $this->assertInstanceOf('Netorare\\View\\Renderer\\MarkdownRenderer', $result);
 }
开发者ID:sasezaki,项目名称:netorare,代码行数:9,代码来源:PathinfoExtensionStrategyTest.php

示例5: testSelectRendererReturnsApiBlueprintRendererWhenApiBlueprintViewModelIsPresentInEvent

 public function testSelectRendererReturnsApiBlueprintRendererWhenApiBlueprintViewModelIsPresentInEvent()
 {
     $event = new ViewEvent();
     $event->setName(ViewEvent::EVENT_RENDERER);
     $event->setModel(new ApiBlueprintModel(array()));
     $event->setRequest(new HttpRequest());
     $renderer = $this->strategy->selectRenderer($event);
     $this->assertSame($this->renderer, $renderer);
     return $event;
 }
开发者ID:BreiteSeite,项目名称:zf-apigility-documentation-apiblueprint,代码行数:10,代码来源:ApiBlueprintViewStrategyTest.php

示例6: render

 /**
  * 
  * @param ModelInterface $model
  * @return string
  */
 public function render(ModelInterface $model)
 {
     $event = new ViewEvent();
     $event->setName(ViewEvent::EVENT_RENDERER);
     $event->setModel($model);
     $renderers = $this->view->getEventManager()->triggerEventUntil(function ($result) {
         return $result instanceof RendererInterface;
     }, $event);
     return $renderers->last()->render($model);
 }
开发者ID:alex-oleshkevich,项目名称:zf-extras,代码行数:15,代码来源:DirectRenderer.php

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

示例8: testProperlyFillViewModelHelperIfRendererIsSelected

 public function testProperlyFillViewModelHelperIfRendererIsSelected()
 {
     $model = new ResourceViewModel();
     $viewEvent = new ViewEvent();
     $viewEvent->setModel($model);
     $viewModelHelper = $this->getMock(ViewModel::class, [], [], '', false);
     $viewModelHelper->expects($this->once())->method('setRoot')->with($model);
     $viewModelHelper->expects($this->once())->method('setCurrent')->with($model);
     $helperManager = $this->getMock(HelperPluginManager::class, [], [], '', false);
     $helperManager->expects($this->once())->method('setRenderer')->with($this->resourceRenderer);
     $helperManager->expects($this->once())->method('get')->with('viewModel')->willReturn($viewModelHelper);
     $this->resourceRenderer->expects($this->once())->method('getHelperPluginManager')->willReturn($helperManager);
     $this->assertSame($this->resourceRenderer, $this->resourceStrategy->selectRenderer($viewEvent));
 }
开发者ID:omusico,项目名称:zfr-rest,代码行数:14,代码来源:ResourceStrategyTest.php

示例9: onRenderer

 /**
  * @param ViewEvent $viewEvent
  *
  * @return PartialRenderer
  */
 public function onRenderer(ViewEvent $viewEvent)
 {
     $model = $viewEvent->getModel();
     $config = $this->getOptions()->getConfig();
     if ($model instanceof ViewModel && in_array($model->getTemplate(), $config)) {
         $success = false;
         $cacheContent = $this->getCacheManager()->getItem($model->getTemplate(), $success);
         if (true === $success) {
             $partialModel = new PartialViewModel();
             $partialModel->setIsCached(true);
             $partialModel->setCacheContent($cacheContent);
             $partialModel->setTemplate($model->getTemplate());
             $viewEvent->setModel($model);
         }
         return $this->getRenderer();
     }
 }
开发者ID:nbochenko,项目名称:cache,代码行数:22,代码来源:PartialStrategy.php

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

示例11: testSelectRendererAndInjectResponse

 public function testSelectRendererAndInjectResponse()
 {
     $renderer = new BlockRenderer();
     $strategy = new BlockRendererStrategy($renderer);
     $viewEvent = new ViewEvent();
     $viewEvent->setModel(new ViewModel());
     $this->assertNull($strategy->selectRenderer($viewEvent));
     $dummyBlock = new Dummy();
     $viewEvent->setModel($dummyBlock);
     $this->assertSame($renderer, $strategy->selectRenderer($viewEvent));
     $this->assertNull($strategy->injectResponse($viewEvent));
     $response = new Response();
     $viewEvent->setRenderer($renderer);
     $viewEvent->setResult('test');
     $viewEvent->setResponse($response);
     $strategy->injectResponse($viewEvent);
     $this->assertEquals('test', $response->getContent());
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:18,代码来源:BlockStrategyTest.php

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

示例13: cleanLayout

 /**
  * remove unwanted or layout related data
  *
  * basically you rake through the viewmodel for the data you want to use for your template,
  * this may not be optimal because you have to rely on the correct naming of the viewmodels
  *
  * if you get the data you want, you switch to the specific template by adding the conforming resolver
  *
  * @param \Zend\View\ViewEvent $e
  */
 public function cleanLayout(ViewEvent $e)
 {
     $result = $e->getResult();
     $response = $e->getResponse();
     $model = $e->getModel();
     if ($model->hasChildren()) {
         $children = $model->getChildren();
         $content = null;
         foreach ($children as $child) {
             if ($child->captureTo() == 'content') {
                 $content = $child;
                 $this->attachViewResolver();
             }
         }
         if (!empty($content)) {
             $e->setModel($content);
         }
     } else {
         // attach the own resolver here too ?
         // ...
     }
 }
开发者ID:utrenkner,项目名称:YAWIK,代码行数:32,代码来源:Module.php

示例14: testSelectRendererApplicable

 public function testSelectRendererApplicable()
 {
     $e = new ViewEvent();
     $e->setModel(new YamlModel());
     $this->assertSame($this->renderer, $this->strategy->selectRenderer($e));
 }
开发者ID:acelaya,项目名称:zf2-acyaml,代码行数:6,代码来源:YamlStrategyTest.php

示例15: testAnotherModel

 public function testAnotherModel()
 {
     $viewEvent = new ViewEvent();
     $viewEvent->setModel(new ViewModel());
     $this->strategy->selectRenderer($viewEvent);
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:6,代码来源:ImageStrategyTest.php


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