Skip to content

Commit

Permalink
Use Escaper Runtime (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer authored Sep 15, 2024
1 parent 549e0f3 commit 418de7c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Twig\Extension\DebugExtension;
use Twig\Extension\ExtensionInterface;
use Twig\Extension\EscaperExtension;
use Twig\Runtime\EscaperRuntime;
use Twig\Loader\ArrayLoader;
use Twig\Loader\ChainLoader;

Expand Down Expand Up @@ -231,7 +232,12 @@ function () {
);

foreach ($this->app['config']->get('twigbridge.twig.safe_classes', []) as $safeClass => $strategy) {
$twig->getExtension(EscaperExtension::class)->addSafeClass($safeClass, $strategy);
// "Since twig/twig 3.10: The "Twig\Extension\EscaperExtension::addSafeClass()" method is deprecated, use the "Twig\Runtime\EscaperRuntime::addSafeClass()" method instead."
if (class_exists(EscaperRuntime::class)) {
$twig->getRuntime(EscaperRuntime::class)->addSafeClass($safeClass, $strategy);
} else {
$twig->getExtension(EscaperExtension::class)->addSafeClass($safeClass, $strategy);
}
}

// Instantiate and add extensions
Expand Down

0 comments on commit 418de7c

Please sign in to comment.