31
31
use Symfony \Component \Console \Command \Command ;
32
32
use Symfony \Component \Console \Input \InputInterface ;
33
33
use Symfony \Component \Mailer \MailerInterface ;
34
+ use Symfony \Component \PasswordHasher \Hasher \UserPasswordHasherInterface ;
35
+ use Symfony \Component \Security \Core \Encoder \UserPasswordEncoderInterface ;
34
36
use Symfony \Component \Yaml \Yaml ;
35
37
use SymfonyCasts \Bundle \ResetPassword \Model \ResetPasswordRequestInterface ;
36
38
use SymfonyCasts \Bundle \ResetPassword \Model \ResetPasswordRequestTrait ;
@@ -186,6 +188,16 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
186
188
'Form \\'
187
189
);
188
190
191
+ /*
192
+ * @legacy Conditional can be removed when MakerBundle no longer
193
+ * supports Symfony < 6.0.
194
+ */
195
+ $ passwordHasher = UserPasswordEncoderInterface::class;
196
+
197
+ if (interface_exists (UserPasswordHasherInterface::class)) {
198
+ $ passwordHasher = UserPasswordHasherInterface::class;
199
+ }
200
+
189
201
$ generator ->generateController (
190
202
$ controllerClassNameDetails ->getFullName (),
191
203
'resetPassword/ResetPasswordController.tpl.php ' ,
@@ -202,6 +214,9 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
202
214
'from_email_name ' => $ this ->fromEmailName ,
203
215
'email_getter ' => $ this ->emailGetterMethodName ,
204
216
'email_field ' => $ this ->emailPropertyName ,
217
+ 'password_class_details ' => ($ passwordClassDetails = $ generator ->createClassNameDetails ($ passwordHasher , '\\' )),
218
+ 'password_variable_name ' => sprintf ('$%s ' , lcfirst ($ passwordClassDetails ->getShortName ())), // @legacy see passwordHasher conditional above
219
+ 'use_password_hasher ' => UserPasswordHasherInterface::class === $ passwordHasher , // @legacy see passwordHasher conditional above
205
220
]
206
221
);
207
222
0 commit comments