diff --git a/src/Maker/MakeForgottenPassword.php b/src/Maker/MakeForgottenPassword.php index 143014118..90a10b1be 100644 --- a/src/Maker/MakeForgottenPassword.php +++ b/src/Maker/MakeForgottenPassword.php @@ -15,23 +15,23 @@ use Symfony\Bundle\MakerBundle\DependencyBuilder; use Symfony\Bundle\MakerBundle\Doctrine\ORMDependencyBuilder; use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException; +use Symfony\Bundle\MakerBundle\FileManager; use Symfony\Bundle\MakerBundle\Generator; use Symfony\Bundle\MakerBundle\InputConfiguration; +use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer; use Symfony\Bundle\MakerBundle\Security\InteractiveSecurityHelper; use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator; use Symfony\Bundle\SecurityBundle\SecurityBundle; +use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle; use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\EmailType; +use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Routing\RouterInterface; -use Symfony\Bundle\MakerBundle\FileManager; -use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer; use Symfony\Component\Validator\Validation; -use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle; /** * @author Romaric Drigon diff --git a/src/Renderer/FormTypeRenderer.php b/src/Renderer/FormTypeRenderer.php index 0911201fb..6e0e10f72 100644 --- a/src/Renderer/FormTypeRenderer.php +++ b/src/Renderer/FormTypeRenderer.php @@ -42,6 +42,9 @@ public function render(ClassNameDetails $formClassDetails, array $formFields, Cl $fields[$name] = $fieldTypeOptions; } + $mergedTypeUseStatements = array_merge($fieldTypeUseStatements, $extraUseClasses); + sort($mergedTypeUseStatements); + $this->generator->generateClass( $formClassDetails->getFullName(), 'form/Type.tpl.php', @@ -49,7 +52,7 @@ public function render(ClassNameDetails $formClassDetails, array $formFields, Cl 'bounded_full_class_name' => $boundClassDetails ? $boundClassDetails->getFullName() : null, 'bounded_class_name' => $boundClassDetails ? $boundClassDetails->getShortName() : null, 'form_fields' => $fields, - 'field_type_use_statements' => array_merge($fieldTypeUseStatements, $extraUseClasses), + 'field_type_use_statements' => $mergedTypeUseStatements, 'constraint_use_statements' => $constraintClasses, ] ); diff --git a/src/Resources/config/makers.xml b/src/Resources/config/makers.xml index 15e3ec6c8..7cb338982 100644 --- a/src/Resources/config/makers.xml +++ b/src/Resources/config/makers.xml @@ -42,12 +42,14 @@ - - - - - - + + + + + + + + diff --git a/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php b/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php index 3947d6dd5..d29214506 100644 --- a/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php +++ b/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php @@ -106,15 +106,15 @@ public function reset(Request $request, UserPasswordEncoderInterface $passwordEn throw $this->createNotFoundException(); } - $passwordResetToken = $this->getDoctrine()->getRepository(PasswordResetToken::class)->findOneBy([ - 'selector' => substr($tokenAndSelector, 0, PasswordResetToken::SELECTOR_LENGTH), + $passwordResetToken = $this->getDoctrine()->getRepository(::class)->findOneBy([ + 'selector' => substr($tokenAndSelector, 0, ::SELECTOR_LENGTH), ]); if (!$passwordResetToken) { throw $this->createNotFoundException(); } - if ($passwordResetToken->isExpired() || !$passwordResetToken->isTokenEquals(substr($tokenAndSelector, PasswordResetToken::SELECTOR_LENGTH))) { + if ($passwordResetToken->isExpired() || !$passwordResetToken->isTokenEquals(substr($tokenAndSelector, ::SELECTOR_LENGTH))) { $this->getDoctrine()->getManager()->remove($passwordResetToken); $this->getDoctrine()->getManager()->flush(); @@ -125,7 +125,7 @@ public function reset(Request $request, UserPasswordEncoderInterface $passwordEn $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - // A PasswordResetToken should be used only once, remove it. + // A should be used only once, remove it. $this->getDoctrine()->getManager()->remove($passwordResetToken); // Encode the plain password, and set it. diff --git a/src/Security/SecurityControllerBuilder.php b/src/Security/SecurityControllerBuilder.php index 3d843bd91..12923fd41 100644 --- a/src/Security/SecurityControllerBuilder.php +++ b/src/Security/SecurityControllerBuilder.php @@ -71,7 +71,7 @@ public function addLogoutMethod(ClassSourceManipulator $manipulator) $manipulator->addUseStatementIfNecessary(Route::class); $manipulator->addMethodBody($logoutMethodBuilder, <<<'CODE' addMethodBuilder($logoutMethodBuilder); diff --git a/tests/Maker/FunctionalTest.php b/tests/Maker/FunctionalTest.php index c9d2e33a2..b555300ba 100644 --- a/tests/Maker/FunctionalTest.php +++ b/tests/Maker/FunctionalTest.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\MakerBundle\Command\MakerCommand; use Symfony\Bundle\MakerBundle\Maker\AbstractMaker; +use Symfony\Bundle\MakerBundle\Maker\MakeForgottenPassword; use Symfony\Bundle\MakerBundle\Test\MakerTestKernel; use Symfony\Component\Finder\Finder; @@ -39,6 +40,11 @@ public function testWiring() continue; } + /** Skip make forgotten password as it is temp. disabled (tkt#537) */ + if (MakeForgottenPassword::class === $class) { + continue; + } + $commandName = $class::getCommandName(); // if the command does not exist, this will explode $command = $application->find($commandName); diff --git a/tests/Maker/MakeForgottenPasswordTest.php b/tests/Maker/MakeForgottenPasswordTest.php index 8d51c181e..6735a02d0 100644 --- a/tests/Maker/MakeForgottenPasswordTest.php +++ b/tests/Maker/MakeForgottenPasswordTest.php @@ -8,8 +8,14 @@ class MakeForgottenPasswordTest extends MakerTestCase { + /** + * Test skipped until make forgotten password is enabled again. + * @see https://github.com/symfony/maker-bundle/issues/537 + */ public function getTestDetails() { + $this->markTestSkipped('Temp. Disabled make forgotten password. See '); + yield 'forgotten_password' => [MakerTestDetails::createTest( $this->getMakerInstance(MakeForgottenPassword::class), [ @@ -21,6 +27,7 @@ public function getTestDetails() ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeForgottenPassword') ->configureDatabase() ->updateSchemaAfterCommand() + ->addExtraDependencies('symfony/swiftmailer-bundle') ]; } } diff --git a/tests/Security/fixtures/expected/SecurityController_login_logout.php b/tests/Security/fixtures/expected/SecurityController_login_logout.php index 000eedc6d..ed5a595b7 100644 --- a/tests/Security/fixtures/expected/SecurityController_login_logout.php +++ b/tests/Security/fixtures/expected/SecurityController_login_logout.php @@ -31,6 +31,6 @@ public function login(AuthenticationUtils $authenticationUtils): Response */ public function logout() { - throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall'); + throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); } }