From b385166fff482a4dd5b6402050b12a9cb3abe502 Mon Sep 17 00:00:00 2001 From: Frank Verhoeven Date: Fri, 7 Oct 2022 15:06:42 +0200 Subject: [PATCH] fix: Also configure `on_retry_callback` if no logger --- src/GuzzleBundleRetryPlugin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GuzzleBundleRetryPlugin.php b/src/GuzzleBundleRetryPlugin.php index 4a62214..2e1a375 100644 --- a/src/GuzzleBundleRetryPlugin.php +++ b/src/GuzzleBundleRetryPlugin.php @@ -95,14 +95,18 @@ public function loadForClient( ): void { if ($config['retry_enabled']) { $onRetryCallback = null; + if ($container->has('monolog.logger.eight_points_guzzle')) { $logger = new Definition(Logger::class); $logger->addMethodCall('setLogger', [new Reference('eight_points_guzzle.logger.class')]); $logger->addMethodCall('setFormatter', [new Reference('eight_points_guzzle.symfony_log_formatter')]); - $onRetryCallback = null !== $config['on_retry_callback'] ? - new Reference($config['on_retry_callback']) : [$logger, 'callback']; + + $onRetryCallback = [$logger, 'callback']; } + $onRetryCallback = null !== $config['on_retry_callback'] ? + new Reference($config['on_retry_callback']) : $onRetryCallback; + $middleware = new Definition(GuzzleRetryMiddleware::class); $middleware->setFactory([GuzzleRetryMiddleware::class, 'factory']); $middleware->setArguments([