コード例 #1
0
 /**
  * @test
  */
 public function controllerContextCanBeReadCorrectly()
 {
     $controllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array('getRequest'), array(), '', false);
     $controllerContext->expects($this->atLeastOnce())->method('getRequest')->willReturn($this->getMock(Request::class));
     $this->renderingContext->setControllerContext($controllerContext);
     $this->assertSame($this->renderingContext->getControllerContext(), $controllerContext);
 }
コード例 #2
0
 /**
  * Loads the template source and render the template.
  * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
  *
  * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
  * @return string Rendered Template
  * @api
  */
 public function render($actionName = NULL)
 {
     $this->baseRenderingContext->setControllerContext($this->controllerContext);
     $this->templateParser->setConfiguration($this->buildParserConfiguration());
     $templateIdentifier = $this->getTemplateIdentifier($actionName);
     if ($this->templateCompiler->has($templateIdentifier)) {
         $parsedTemplate = $this->templateCompiler->get($templateIdentifier);
     } else {
         $parsedTemplate = $this->templateParser->parse($this->getTemplateSource($actionName));
         if ($parsedTemplate->isCompilable()) {
             $this->templateCompiler->store($templateIdentifier, $parsedTemplate);
         }
     }
     if ($parsedTemplate->hasLayout()) {
         $layoutName = $parsedTemplate->getLayoutName($this->baseRenderingContext);
         $layoutIdentifier = $this->getLayoutIdentifier($layoutName);
         if ($this->templateCompiler->has($layoutIdentifier)) {
             $parsedLayout = $this->templateCompiler->get($layoutIdentifier);
         } else {
             $parsedLayout = $this->templateParser->parse($this->getLayoutSource($layoutName));
             if ($parsedLayout->isCompilable()) {
                 $this->templateCompiler->store($layoutIdentifier, $parsedLayout);
             }
         }
         $this->startRendering(self::RENDERING_LAYOUT, $parsedTemplate, $this->baseRenderingContext);
         $output = $parsedLayout->render($this->baseRenderingContext);
         $this->stopRendering();
     } else {
         $this->startRendering(self::RENDERING_TEMPLATE, $parsedTemplate, $this->baseRenderingContext);
         $output = $parsedTemplate->render($this->baseRenderingContext);
         $this->stopRendering();
     }
     return $output;
 }
コード例 #3
0
 /**
  * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
  * @return void
  */
 protected function prepareContextsForUncachedRendering(RenderingContextInterface $renderingContext, ControllerContext $controllerContext)
 {
     $renderingContext->setControllerContext($controllerContext);
     $this->setRenderingContext($renderingContext);
     $this->templateParser = TemplateParserBuilder::build();
     $this->templateCompiler = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler');
     $this->templateCompiler->setTemplateCache($GLOBALS['typo3CacheManager']->getCache('fluid_template'));
 }
コード例 #4
0
 /**
  * @test
  */
 public function controllerContextCanBeReadCorrectly()
 {
     $controllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->renderingContext->setControllerContext($controllerContext);
     $this->assertSame($this->renderingContext->getControllerContext(), $controllerContext);
 }
コード例 #5
0
 /**
  * @test
  */
 public function controllerContextCanBeReadCorrectly()
 {
     $controllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array(), array(), '', false);
     $this->renderingContext->setControllerContext($controllerContext);
     $this->assertSame($this->renderingContext->getControllerContext(), $controllerContext);
 }