Neos\Neos\View\TypoScriptView::render PHP Method

render() public method

Renders the view
public render ( ) : string
return string The rendered view
    public function render()
    {
        $currentNode = $this->getCurrentNode();
        $currentSiteNode = $currentNode->getContext()->getCurrentSiteNode();
        $typoScriptRuntime = $this->getTypoScriptRuntime($currentSiteNode);
        $dimensions = $currentNode->getContext()->getDimensions();
        if (array_key_exists('language', $dimensions) && $dimensions['language'] !== array()) {
            $currentLocale = new Locale($dimensions['language'][0]);
            $this->i18nService->getConfiguration()->setCurrentLocale($currentLocale);
            $this->i18nService->getConfiguration()->setFallbackRule(array('strict' => false, 'order' => array_reverse($dimensions['language'])));
        }
        $typoScriptRuntime->pushContextArray(array('node' => $currentNode, 'documentNode' => $this->getClosestDocumentNode($currentNode) ?: $currentNode, 'site' => $currentSiteNode, 'editPreviewMode' => isset($this->variables['editPreviewMode']) ? $this->variables['editPreviewMode'] : null));
        try {
            $output = $typoScriptRuntime->render($this->typoScriptPath);
            $output = $this->mergeHttpResponseFromOutput($output, $typoScriptRuntime);
        } catch (RuntimeException $exception) {
            throw $exception->getPrevious();
        }
        $typoScriptRuntime->popContext();
        return $output;
    }

Usage Example

 /**
  * @test
  */
 public function renderPutsSiteNodeInTypoScriptContext()
 {
     $this->setUpMockView();
     $this->mockRuntime->expects($this->once())->method('pushContextArray')->with($this->arrayHasKey('site'));
     $this->mockView->render();
 }