Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[RateLimiter] Add RateLimiterFactoryInterface #58939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -27,4 +28,9 @@
null,
])
;

if (interface_exists(RateLimiterFactoryInterface::class)) {
$container->services()
->alias(RateLimiterFactoryInterface::class, 'limiter');
}
};
5 changes: 5 additions & 0 deletions src/Symfony/Component/RateLimiter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.3
---

* Add `RateLimiterFactoryInterface`

6.4
---

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/RateLimiter/RateLimiterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* @author Wouter de Jong <[email protected]>
*/
final class RateLimiterFactory
final class RateLimiterFactory implements RateLimiterFactoryInterface
{
private array $config;

Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/Symfony/Component/RateLimiter/RateLimiterFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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 <[email protected]>
*/
interface RateLimiterFactoryInterface
{
/**
* @param string|null $key an optional key used to identify the limiter
*/
public function create(?string $key = null): LimiterInterface;
}