Skip to content

Commit 231a5f1

Browse files
committed
[RateLimiter] Move lock component to dev dependency
1 parent dbc3aed commit 231a5f1

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;
@@ -2679,8 +2680,11 @@ public static function registerRateLimiter(ContainerBuilder $container, string $
26792680
$limiter = $container->setDefinition($limiterId = 'limiter.'.$name, new ChildDefinition('limiter'));
26802681

26812682
if (null !== $limiterConfig['lock_factory']) {
2683+
if (!interface_exists(LockInterface::class)) {
2684+
throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be installed. Try running "composer require symfony/lock".', $name));
2685+
}
26822686
if (!self::$lockConfigEnabled) {
2683-
throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be installed and configured.', $name));
2687+
throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be configured.', $name));
26842688
}
26852689

26862690
$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)