Skip to content

Commit

Permalink
Merge pull request #17 from norkunas/sanitizer-autowiring-by-name
Browse files Browse the repository at this point in the history
Autowire sanitizers via interface by name
  • Loading branch information
tgalopin authored Jan 27, 2021
2 parents df42087 + 304a876 commit 87e07ce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/DependencyInjection/HtmlSanitizerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit 87e07ce

Please sign in to comment.