Skip to content

Commit 8ca25e0

Browse files
committed
bug #1017 [reset-password] fix missing entity manager di (jrushlow)
This PR was merged into the 1.0-dev branch. Discussion ---------- [reset-password] fix missing entity manager di DI the `EntityManagerInterface` into the constructor as the private method is ultimately called in https://github.com/symfony/maker-bundle/blob/63dc8ba1089f7ab7ae400b03dbee347f8b631275/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php#L41 as well as the public `reset` method as well. Commits ------- 1043749 [reset-password] fix missing entity manager di
2 parents 63dc8ba + 1043749 commit 8ca25e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ class <?= $class_name ?> extends AbstractController
1616
use ResetPasswordControllerTrait;
1717

1818
private $resetPasswordHelper;
19+
private $entityManager;
1920

20-
public function __construct(ResetPasswordHelperInterface $resetPasswordHelper)
21+
public function __construct(ResetPasswordHelperInterface $resetPasswordHelper, EntityManagerInterface $entityManager)
2122
{
2223
$this->resetPasswordHelper = $resetPasswordHelper;
24+
$this->entityManager = $entityManager;
2325
}
2426

2527
/**
@@ -82,7 +84,7 @@ public function checkEmail(): Response
8284
* @Route("/reset/{token}", name="app_reset_password")
8385
*/
8486
<?php } ?>
85-
public function reset(Request $request, <?= $password_hasher_class_details->getShortName() ?> <?= $password_hasher_variable_name ?>, EntityManagerInterface $entityManager, string $token = null): Response
87+
public function reset(Request $request, <?= $password_hasher_class_details->getShortName() ?> <?= $password_hasher_variable_name ?>, string $token = null): Response
8688
{
8789
if ($token) {
8890
// We store the token in session and remove it from the URL, to avoid the URL being
@@ -123,7 +125,7 @@ public function reset(Request $request, <?= $password_hasher_class_details->getS
123125
);
124126

125127
$user-><?= $password_setter ?>($encodedPassword);
126-
$entityManager->flush();
128+
$this->entityManager->flush();
127129

128130
// The session is cleaned up after the password has been changed.
129131
$this->cleanSessionAfterReset();
@@ -136,9 +138,9 @@ public function reset(Request $request, <?= $password_hasher_class_details->getS
136138
]);
137139
}
138140

139-
private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer, EntityManagerInterface $entityManager): RedirectResponse
141+
private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse
140142
{
141-
$user = $entityManager->getRepository(<?= $user_class_name ?>::class)->findOneBy([
143+
$user = $this->entityManager->getRepository(<?= $user_class_name ?>::class)->findOneBy([
142144
'<?= $email_field ?>' => $emailFormData,
143145
]);
144146

0 commit comments

Comments
 (0)