stfalcon / TinymceBundle

Bundle for connecting TinyMCE (WYSIWYG editor) to your Symfony2 project
259 stars 154 forks source link

Twig Extension Symfony 6 init twig - solution #265

Open mviraghu opened 4 months ago

mviraghu commented 4 months ago

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,
            ]
        );
}