88use Exercise \HTMLPurifierBundle \HTMLPurifiersRegistryInterface ;
99use Symfony \Component \Config \FileLocator ;
1010use Symfony \Component \DependencyInjection \ContainerBuilder ;
11- use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
12- use Symfony \Component \DependencyInjection \Reference ;
1311use Symfony \Component \DependencyInjection \Extension \Extension ;
12+ use Symfony \Component \DependencyInjection \Loader \PhpFileLoader ;
13+ use Symfony \Component \DependencyInjection \Reference ;
1414
1515class ExerciseHTMLPurifierExtension extends Extension
1616{
1717 public function load (array $ configs , ContainerBuilder $ container ): void
1818 {
19- $ loader = new XmlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
19+ $ loader = new PhpFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
2020
21- $ loader ->load ('html_purifier.xml ' );
21+ $ loader ->load ('services.php ' );
2222
2323 $ configs = $ this ->processConfiguration (new Configuration (), $ configs );
2424
@@ -30,8 +30,6 @@ public function load(array $configs, ContainerBuilder $container): void
3030 }
3131
3232 $ serializerPaths = [];
33- // Drop when require Symfony > 3.4
34- $ registerAlias = method_exists ($ container , 'registerAliasForArgument ' );
3533
3634 foreach ($ configs ['html_profiles ' ] as $ name => $ definition ) {
3735 $ configId = "exercise_html_purifier.config. $ name " ;
@@ -71,7 +69,7 @@ public function load(array $configs, ContainerBuilder $container): void
7169 $ serializerPaths [] = $ definition ['config ' ]['Cache.SerializerPath ' ];
7270 }
7371
74- if ($ registerAlias && $ default ) {
72+ if ($ default ) {
7573 $ container ->registerAliasForArgument ($ id , \HTMLPurifier::class, "$ name.purifier " );
7674 }
7775 }
0 commit comments