diff --git a/CoopTilleulsForgotPasswordBundle.php b/CoopTilleulsForgotPasswordBundle.php index 91e1fbe..f60576a 100644 --- a/CoopTilleulsForgotPasswordBundle.php +++ b/CoopTilleulsForgotPasswordBundle.php @@ -13,6 +13,8 @@ namespace CoopTilleuls\ForgotPasswordBundle; +use CoopTilleuls\ForgotPasswordBundle\DependencyInjection\CompilerPass\ApiPlatformCompilerPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; /** @@ -20,4 +22,8 @@ */ final class CoopTilleulsForgotPasswordBundle extends Bundle { + public function build(ContainerBuilder $container): void + { + $container->addCompilerPass(new ApiPlatformCompilerPass()); + } } diff --git a/DependencyInjection/CompilerPass/ApiPlatformCompilerPass.php b/DependencyInjection/CompilerPass/ApiPlatformCompilerPass.php new file mode 100644 index 0000000..cfce56a --- /dev/null +++ b/DependencyInjection/CompilerPass/ApiPlatformCompilerPass.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace CoopTilleuls\ForgotPasswordBundle\DependencyInjection\CompilerPass; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * @author Vincent Chalamon + */ +final class ApiPlatformCompilerPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container): void + { + if (!$container->hasDefinition('api_platform.swagger.normalizer.documentation')) { + $container->removeDefinition('coop_tilleuls_forgot_password.normalizer.documentation'); + } + + if (!$container->hasDefinition('api_platform.openapi.factory')) { + $container->removeDefinition('coop_tilleuls_forgot_password.openapi.factory'); + } + } +} diff --git a/DependencyInjection/CoopTilleulsForgotPasswordExtension.php b/DependencyInjection/CoopTilleulsForgotPasswordExtension.php index 5208cf4..b14dcc8 100644 --- a/DependencyInjection/CoopTilleulsForgotPasswordExtension.php +++ b/DependencyInjection/CoopTilleulsForgotPasswordExtension.php @@ -61,13 +61,5 @@ public function load(array $configs, ContainerBuilder $container): void $class = true === $config['use_jms_serializer'] ? JMSNormalizer::class : SymfonyNormalizer::class; $serializerId = true === $config['use_jms_serializer'] ? 'jms_serializer.serializer' : 'serializer'; $container->setDefinition('coop_tilleuls_forgot_password.normalizer', new Definition($class, [new Reference($serializerId)]))->setPublic(false); - - if (!$container->hasDefinition('api_platform.swagger.normalizer.documentation')) { - $container->removeDefinition('coop_tilleuls_forgot_password.normalizer.documentation'); - } - - if (!$container->hasDefinition('api_platform.openapi.factory')) { - $container->removeDefinition('coop_tilleuls_forgot_password.openapi.factory'); - } } }