Skip to content

Commit 38d4323

Browse files
committed
[FrameworkBundle] Deprecated the registerRateLimiter method
1 parent 7cbdd67 commit 38d4323

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ CHANGELOG
2121
* Deprecate `framework.form.legacy_error_messages` config node
2222
* Add a `framework.router.cache_dir` configuration option to configure the default `Router` `cache_dir` option
2323
* Add option `framework.messenger.buses.*.default_middleware.allow_no_senders` to enable throwing when a message doesn't have a sender
24+
* Deprecate `AbstractController::renderForm()`, use `render()` instead
25+
* Deprecate `FrameworkExtension::registerRateLimiter()`, to be made private in 7.0
2426

2527
6.1
2628
---

DependencyInjection/FrameworkExtension.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,12 +2653,20 @@ private function registerRateLimiterConfiguration(array $config, ContainerBuilde
26532653
$loader->load('rate_limiter.php');
26542654

26552655
foreach ($config['limiters'] as $name => $limiterConfig) {
2656-
self::registerRateLimiter($container, $name, $limiterConfig);
2656+
self::registerRateLimiter($container, $name, $limiterConfig, false);
26572657
}
26582658
}
26592659

2660+
/**
2661+
* @deprecated since Symfony 6.2, to be made private in 7.0
2662+
*/
26602663
public static function registerRateLimiter(ContainerBuilder $container, string $name, array $limiterConfig)
26612664
{
2665+
if (\func_num_args() < 4 || false !== func_get_arg(3)) {
2666+
// in Symfony 7.0: convert the method in private non-static, remove this trigger_deprecation and change the call from the registerRateLimiterConfiguration method
2667+
trigger_deprecation('symfony/framework-bundle', '6.2', 'The "%s()" method is deprecated, to be made private in 7.0.', __METHOD__);
2668+
}
2669+
26622670
// default configuration (when used by other DI extensions)
26632671
$limiterConfig += ['lock_factory' => 'lock.factory', 'cache_pool' => 'cache.rate_limiter'];
26642672

@@ -2676,14 +2684,12 @@ public static function registerRateLimiter(ContainerBuilder $container, string $
26762684
}
26772685
unset($limiterConfig['lock_factory']);
26782686

2679-
$storageId = $limiterConfig['storage_service'] ?? null;
2680-
if (null === $storageId) {
2687+
if (null === $storageId = $limiterConfig['storage_service'] ?? null) {
26812688
$container->register($storageId = 'limiter.storage.'.$name, CacheStorage::class)->addArgument(new Reference($limiterConfig['cache_pool']));
26822689
}
26832690

26842691
$limiter->replaceArgument(1, new Reference($storageId));
2685-
unset($limiterConfig['storage_service']);
2686-
unset($limiterConfig['cache_pool']);
2692+
unset($limiterConfig['storage_service'], $limiterConfig['cache_pool']);
26872693

26882694
$limiterConfig['id'] = $name;
26892695
$limiter->replaceArgument(0, $limiterConfig);

0 commit comments

Comments
 (0)