Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig Extension Symfony 6 init twig - solution #265

Open
mviraghu opened this issue May 6, 2024 · 0 comments
Open

Twig Extension Symfony 6 init twig - solution #265

mviraghu opened this issue May 6, 2024 · 0 comments

Comments

@mviraghu
Copy link

mviraghu commented May 6, 2024

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,
            ]
        );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant