Skip to content

Commit 1d33789

Browse files
committed
fix: avoir deprecated use in 6.2
1 parent 7fe9fc1 commit 1d33789

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Maker/MakeAuthenticator.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Bundle\MakerBundle\Util\YamlManipulationFailedException;
2929
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
3030
use Symfony\Bundle\MakerBundle\Validator;
31+
use Symfony\Bundle\SecurityBundle\Security;
3132
use Symfony\Bundle\SecurityBundle\SecurityBundle;
3233
use Symfony\Bundle\TwigBundle\TwigBundle;
3334
use Symfony\Component\Console\Command\Command;
@@ -42,7 +43,7 @@
4243
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
4344
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
4445
use Symfony\Component\Security\Core\Exception\AuthenticationException;
45-
use Symfony\Component\Security\Core\Security;
46+
use Symfony\Component\Security\Core\Security as LegacySecurity;
4647
use Symfony\Component\Security\Guard\AuthenticatorInterface as GuardAuthenticatorInterface;
4748
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
4849
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
@@ -273,14 +274,20 @@ private function generateAuthenticatorClass(array $securityData, string $authent
273274
$useStatements->addUseStatement([
274275
RedirectResponse::class,
275276
UrlGeneratorInterface::class,
276-
Security::class,
277277
AbstractLoginFormAuthenticator::class,
278278
CsrfTokenBadge::class,
279279
UserBadge::class,
280280
PasswordCredentials::class,
281281
TargetPathTrait::class,
282282
]);
283283

284+
// @legacy - Can be removed when Symfony 5.4 support is dropped
285+
if(class_exists(Security::class)) {
286+
$useStatements->addUseStatement(Security::class);
287+
} else {
288+
$useStatements->addUseStatement(LegacySecurity::class);
289+
}
290+
284291
$userClassNameDetails = $this->generator->createClassNameDetails(
285292
'\\'.$userClass,
286293
'Entity\\'

0 commit comments

Comments
 (0)