From 304a8764746268223d38132b43b9cb979a058a69 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 15 Jan 2021 13:39:18 +0200 Subject: [PATCH] Autowire sanitizers via interface by name --- src/DependencyInjection/HtmlSanitizerExtension.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/DependencyInjection/HtmlSanitizerExtension.php b/src/DependencyInjection/HtmlSanitizerExtension.php index c14fbe5..60c6efd 100644 --- a/src/DependencyInjection/HtmlSanitizerExtension.php +++ b/src/DependencyInjection/HtmlSanitizerExtension.php @@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\HttpKernel\Kernel; use Twig\Environment; /** @@ -75,6 +76,10 @@ private function registerSanitizers(ContainerBuilder $container, array $sanitize $container->setAlias('html_sanitizer', 'html_sanitizer.'.$name); } + if (Kernel::VERSION_ID > 40200) { + $container->registerAliasForArgument('html_sanitizer.'.$name, SanitizerInterface::class, $name); + } + $refMap[$name] = new ServiceClosureArgument(new Reference('html_sanitizer.'.$name)); }