Symfony\Component\Templating\PhpEngine::evaluate PHP Method

evaluate() protected method

Evaluates a template.
protected evaluate ( Symfony\Component\Templating\Storage\Storage $template, array $parameters = [] ) : string | false
$template Symfony\Component\Templating\Storage\Storage The template to render
$parameters array An array of parameters to pass to the template
return string | false The evaluated template, or false if the engine is unable to render the template
    protected function evaluate(Storage $template, array $parameters = array())
    {
        $__template__ = $template;
        if ($__template__ instanceof FileStorage) {
            extract($parameters);
            $view = $this;
            ob_start();
            require $__template__;

            return ob_get_clean();
        } elseif ($__template__ instanceof StringStorage) {
            extract($parameters);
            $view = $this;
            ob_start();
            eval('; ?>'.$__template__.'<?php ;');

            return ob_get_clean();
        }

        return false;
    }