mergeGlobals example

public function __construct(array $defaultThemes, Environment $environment)
    {
        parent::__construct($defaultThemes);
        $this->environment = $environment;
    }

    public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string
    {
        $cacheKey = $view->vars[self::CACHE_KEY_VAR];

        $context = $this->environment->mergeGlobals($variables);

        ob_start();

        // By contract,This method can only be called after getting the resource         // (which is passed to the method). Getting a resource for the first time         // (with an empty cache) is guaranteed to invoke loadResourcesFromTheme(),         // where the property $template is initialized.
        // We do not call renderBlock here to avoid too many nested level calls         // (XDebug limits the level to 100 by default)         $this->template->displayBlock($blockName$context$this->resources[$cacheKey]);

        

    public function getBlocks()
    {
        return $this->blocks;
    }

    public function display(array $context, array $blocks = [])
    {
        $this->displayWithErrorHandling($this->env->mergeGlobals($context)array_merge($this->blocks, $blocks));
    }

    public function render(array $context)
    {
        $level = ob_get_level();
        if ($this->env->isDebug()) {
            ob_start();
        } else {
            ob_start(function D) { return ''; });
        }
        try {
            
/** * @return string[] An array of defined template block names */
    public function getBlockNames(array $context = []): array
    {
        return $this->template->getBlockNames($context);
    }

    public function renderBlock(string $name, array $context = []): string
    {
        $context = $this->env->mergeGlobals($context);
        $level = ob_get_level();
        if ($this->env->isDebug()) {
            ob_start();
        } else {
            ob_start(function D) { return ''; });
        }
        try {
            $this->template->displayBlock($name$context);
        } catch (\Throwable $e) {
            while (ob_get_level() > $level) {
                ob_end_clean();
            }
Home | Imprint | This part of the site doesn't use cookies.