Twig icon indicating copy to clipboard operation
Twig copied to clipboard

EscaperRuntime::setSafeClasses() implementation

Open joeworkman opened this issue 7 months ago • 2 comments

My Twig extension implements a global that is an adapter for my CMS.

public function getGlobals(): array
{
    return [
            'cms' => $this->adapter,
    ];
}

I would like to set all functions for this class to be safe. I thought that I could use EscaperRuntime::setSafeClasses() for this.

$this->twig->getRuntime(EscaperRuntime::class)->setSafeClasses([
	TotalForm::class           => ['html'],
	TotalCMSTwigAdapter::class => ['html'],
]);

It's not working. Am I close?

joeworkman avatar Jun 28 '24 19:06 joeworkman