Skip to content

Commit 7cbdd67

Browse files
committed
minor #47926 [RateLimiter] Move lock component to dev dependency (HypeMC)
This PR was merged into the 6.2 branch. Discussion ---------- [RateLimiter] Move lock component to dev dependency | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #47277 | License | MIT | Doc PR | - Since using locks is an optional feature of the rate limiter component, there's no need for the lock component to be a hard dependency. Commits ------- 31aa3a7d16 [RateLimiter] Move lock component to dev dependency
2 parents b67c0ca + 231a5f1 commit 7cbdd67

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
9292
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9393
use Symfony\Component\Lock\LockFactory;
94+
use Symfony\Component\Lock\LockInterface;
9495
use Symfony\Component\Lock\PersistingStoreInterface;
9596
use Symfony\Component\Lock\Store\StoreFactory;
9697
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
@@ -2664,8 +2665,11 @@ public static function registerRateLimiter(ContainerBuilder $container, string $
26642665
$limiter = $container->setDefinition($limiterId = 'limiter.'.$name, new ChildDefinition('limiter'));
26652666

26662667
if (null !== $limiterConfig['lock_factory']) {
2668+
if (!interface_exists(LockInterface::class)) {
2669+
throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be installed. Try running "composer require symfony/lock".', $name));
2670+
}
26672671
if (!self::$lockConfigEnabled) {
2668-
throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be installed and configured.', $name));
2672+
throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be configured.', $name));
26692673
}
26702674

26712675
$limiter->replaceArgument(2, new Reference($limiterConfig['lock_factory']));

Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testRateLimiterWithLockFactory()
103103

104104
$this->fail('No LogicException thrown');
105105
} catch (LogicException $e) {
106-
$this->assertEquals('Rate limiter "with_lock" requires the Lock component to be installed and configured.', $e->getMessage());
106+
$this->assertEquals('Rate limiter "with_lock" requires the Lock component to be configured.', $e->getMessage());
107107
}
108108

109109
$container = $this->createContainerFromClosure(function (ContainerBuilder $container) {

0 commit comments

Comments
 (0)