|
28 | 28 | use Symfony\Bundle\MakerBundle\Util\YamlManipulationFailedException;
|
29 | 29 | use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
|
30 | 30 | use Symfony\Bundle\MakerBundle\Validator;
|
| 31 | +use Symfony\Bundle\SecurityBundle\Security; |
31 | 32 | use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
32 | 33 | use Symfony\Bundle\TwigBundle\TwigBundle;
|
33 | 34 | use Symfony\Component\Console\Command\Command;
|
|
42 | 43 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
43 | 44 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
44 | 45 | use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
45 |
| -use Symfony\Component\Security\Core\Security; |
| 46 | +use Symfony\Component\Security\Core\Security as LegacySecurity; |
46 | 47 | use Symfony\Component\Security\Guard\AuthenticatorInterface as GuardAuthenticatorInterface;
|
47 | 48 | use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
48 | 49 | use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
|
@@ -273,14 +274,20 @@ private function generateAuthenticatorClass(array $securityData, string $authent
|
273 | 274 | $useStatements->addUseStatement([
|
274 | 275 | RedirectResponse::class,
|
275 | 276 | UrlGeneratorInterface::class,
|
276 |
| - Security::class, |
277 | 277 | AbstractLoginFormAuthenticator::class,
|
278 | 278 | CsrfTokenBadge::class,
|
279 | 279 | UserBadge::class,
|
280 | 280 | PasswordCredentials::class,
|
281 | 281 | TargetPathTrait::class,
|
282 | 282 | ]);
|
283 | 283 |
|
| 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 | + |
284 | 291 | $userClassNameDetails = $this->generator->createClassNameDetails(
|
285 | 292 | '\\'.$userClass,
|
286 | 293 | 'Entity\\'
|
|
0 commit comments