diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 97fa33a3c5eb3..9c9aecbd57eaf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -9,6 +9,7 @@ CHANGELOG * Add JsonEncoder services and configuration * Add new `framework.property_info.with_constructor_extractor` option to allow enabling or disabling the constructor extractor integration * Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown + * Add `RateLimiterFactoryInterface` as an alias of the `limiter` service 7.2 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php index 727a1f6364456..90af4d7588f1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; use Symfony\Component\RateLimiter\RateLimiterFactory; +use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; return static function (ContainerConfigurator $container) { $container->services() @@ -27,4 +28,9 @@ null, ]) ; + + if (interface_exists(RateLimiterFactoryInterface::class)) { + $container->services() + ->alias(RateLimiterFactoryInterface::class, 'limiter'); + } }; diff --git a/src/Symfony/Component/RateLimiter/CHANGELOG.md b/src/Symfony/Component/RateLimiter/CHANGELOG.md index dd9ae3153e675..be236e4142f9a 100644 --- a/src/Symfony/Component/RateLimiter/CHANGELOG.md +++ b/src/Symfony/Component/RateLimiter/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Add `RateLimiterFactoryInterface` + 6.4 --- diff --git a/src/Symfony/Component/RateLimiter/RateLimiterFactory.php b/src/Symfony/Component/RateLimiter/RateLimiterFactory.php index 304d2944d289f..2c27ede775541 100644 --- a/src/Symfony/Component/RateLimiter/RateLimiterFactory.php +++ b/src/Symfony/Component/RateLimiter/RateLimiterFactory.php @@ -24,7 +24,7 @@ /** * @author Wouter de Jong */ -final class RateLimiterFactory +final class RateLimiterFactory implements RateLimiterFactoryInterface { private array $config; @@ -53,7 +53,7 @@ public function create(?string $key = null): LimiterInterface }; } - protected static function configureOptions(OptionsResolver $options): void + private static function configureOptions(OptionsResolver $options): void { $intervalNormalizer = static function (Options $options, string $interval): \DateInterval { // Create DateTimeImmutable from unix timesatmp, so the default timezone is ignored and we don't need to diff --git a/src/Symfony/Component/RateLimiter/RateLimiterFactoryInterface.php b/src/Symfony/Component/RateLimiter/RateLimiterFactoryInterface.php new file mode 100644 index 0000000000000..968760992a4f6 --- /dev/null +++ b/src/Symfony/Component/RateLimiter/RateLimiterFactoryInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\RateLimiter; + +/** + * @author Alexandre Daubois + */ +interface RateLimiterFactoryInterface +{ + /** + * @param string|null $key an optional key used to identify the limiter + */ + public function create(?string $key = null): LimiterInterface; +}