Twig
Twig copied to clipboard
EscaperRuntime::setSafeClasses() implementation
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?