Neos\Fusion\View\FusionView::render PHP Метод

render() публичный Метод

Render the view
public render ( ) : string
Результат string The rendered view
    public function render()
    {
        $this->initializeTypoScriptRuntime();
        if ($this->typoScriptRuntime->canRender($this->getTypoScriptPathForCurrentRequest()) || $this->fallbackViewEnabled === false) {
            return $this->renderTypoScript();
        } else {
            return $this->renderFallbackView();
        }
    }

Usage Example

 /**
  * Evaluate the Fusion object at $path and return the rendered result.
  *
  * @param string $path Relative Fusion path to be rendered
  * @param array $context Additional context variables to be set.
  * @param string $typoScriptPackageKey The key of the package to load Fusion from, if not from the current context.
  * @return string
  * @throws \InvalidArgumentException
  */
 public function render($path, array $context = null, $typoScriptPackageKey = null)
 {
     if (strpos($path, '/') === 0 || strpos($path, '.') === 0) {
         throw new \InvalidArgumentException('When calling the Fusion render view helper only relative paths are allowed.', 1368740480);
     }
     if (preg_match('/^[a-z0-9.]+$/i', $path) !== 1) {
         throw new \InvalidArgumentException('Invalid path given to the Fusion render view helper ', 1368740484);
     }
     $slashSeparatedPath = str_replace('.', '/', $path);
     if ($typoScriptPackageKey === null) {
         /** @var $typoScriptObject AbstractTypoScriptObject */
         $typoScriptObject = $this->viewHelperVariableContainer->getView()->getTypoScriptObject();
         if ($context !== null) {
             $currentContext = $typoScriptObject->getTsRuntime()->getCurrentContext();
             foreach ($context as $key => $value) {
                 $currentContext[$key] = $value;
             }
             $typoScriptObject->getTsRuntime()->pushContextArray($currentContext);
         }
         $absolutePath = $typoScriptObject->getPath() . '/' . $slashSeparatedPath;
         $output = $typoScriptObject->getTsRuntime()->render($absolutePath);
         if ($context !== null) {
             $typoScriptObject->getTsRuntime()->popContext();
         }
     } else {
         $this->initializeFusionView();
         $this->typoScriptView->setPackageKey($typoScriptPackageKey);
         $this->typoScriptView->setTypoScriptPath($slashSeparatedPath);
         if ($context !== null) {
             $this->typoScriptView->assignMultiple($context);
         }
         $output = $this->typoScriptView->render();
     }
     return $output;
 }