Skip to content

Twig Extension Symfony 6 init twig - solution #265

@mviraghu

Description

@mviraghu

Hi, can you update the class StfalconTinymceExtension Twig Extension with the following code, please... This can work with Symfony 6 too.

use Environment

use Twig\Environment;

Insert 'needs_environment' => true

public function getFunctions(): array
    {
        return [
            'tinymce_init' => new TwigFunction(
                'tinymce_init',
                [$this, 'tinymceInit'],
                ['needs_environment' => true,
                    'is_safe' => ['html']]
            ),
        ];
    }

Environment $environment as param
return $environment->render ...

public function tinymceInit(Environment $environment, $options = []): string
    {

CODE BEFORE 

return $environment->render(
            '@StfalconTinymce/Script/init.html.twig',
            [
                'tinymce_config' => $tinymceConfiguration,
                'include_jquery' => $config['include_jquery'],
                'tinymce_jquery' => $config['tinymce_jquery'],
                'asset_package_name' => $assetPackageName,
                'base_url' => $this->baseUrl,
            ]
        );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions