-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
[make:user] implement getUserIdentifier if required #862
[make:user] implement getUserIdentifier if required #862
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus the tests and one comment, this is looking very nice 👍
f5f7198
to
8a75a11
Compare
@@ -3,7 +3,7 @@ | |||
namespace <?= $namespace; ?>; | |||
|
|||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException; | |||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; | |||
use Symfony\Component\Security\Core\Exception\<?= $uses_user_identifier ? 'UserNotFoundException' : 'UsernameNotFoundException' ?>; | |||
<?= ($password_upgrader = interface_exists('Symfony\Component\Security\Core\User\PasswordUpgraderInterface')) ? "use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;\n" : '' ?> | |||
use Symfony\Component\Security\Core\User\UserInterface; | |||
use Symfony\Component\Security\Core\User\UserProviderInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to, at some point, write a util class where we plug all the use
statements into... then we just dump echo $useStatements->render()
in the template :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No kidding.. use statements are getting harder and harder to manage lately.. have a solution on the todo list ;)
$getterIdentifierName = 'getUsername'; | ||
|
||
// Check if we're using Symfony 5.3+ - UserInterface::getUsername() was replaced with UserInterface::getUserIdentifier() | ||
if (class_exists(InMemoryUser::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class DOES only exist on 5.3. But why did you choose this class specifically? Could we use something more direct like method_exists(Symfony\Component\Security\Core\User\User::class, 'getUserIdentifier')
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User::class
has been deprecated as of 5.3 && Renamed / Will be renamed to InMemoryUser::class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one tiny comment!
276e77c
to
1d83924
Compare
Thanks Jesse! |
handle
getUsername()
->getUserIdentifier()
in Symfony 5.3 symfony/symfony#40403