Skip to content

Commit 41ece84

Browse files
committed
cleanup
1 parent 930aaa2 commit 41ece84

38 files changed

Lines changed: 566 additions & 877 deletions

‎.php_cs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use PhpCsFixer\Config;
46
use PhpCsFixer\Finder;
57

@@ -55,5 +57,14 @@ return Config::create()
5557
->setCacheFile(__DIR__.'/var/php-cs-fixer.cache')
5658
->setRules($rules)
5759
->setRiskyAllowed(true)
58-
->setFinder(Finder::create()->in(__DIR__))
60+
->setFinder(Finder::create()
61+
->in([
62+
__DIR__.'/src',
63+
__DIR__.'/tests',
64+
])
65+
->append([__FILE__])
66+
->exclude([
67+
'UserBundle/Resources/skeleton',
68+
])
69+
)
5970
;

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ phpunit-coverage:
3939

4040
# code style / static analysis
4141
cs:
42-
${qa} php-cs-fixer fix --dry-run --verbose --diff --config=.php_cs src/ tests/
42+
${qa} php-cs-fixer fix --dry-run --verbose --diff
4343
cs-fix:
44-
${qa} php-cs-fixer fix --config=.php_cs src/ tests/
44+
${qa} php-cs-fixer fix
4545
sa: install
4646
mkdir -p $$(find src/ -mindepth 1 -maxdepth 1 -type d -print -quit)/vendor
4747
#${qa} phpstan analyse # https://github.com/jakzal/phpqa/issues/139

‎src/UserBundle/DependencyInjection/Extension.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function load(array $configs, ContainerBuilder $container): void
8080
}
8181

8282
if (FeatureDetection::hasSecurityBundle($container)) {
83-
$loader->load('security.php');
83+
$loader->load('security.tpl.php');
8484
}
8585

8686
if (FeatureDetection::hasTwigBundle($container)) {

‎src/UserBundle/Maker/UserMaker.php‎

Lines changed: 90 additions & 137 deletions
Large diffs are not rendered by default.

‎src/UserBundle/Resources/skeleton/config.php‎

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?= "<?php\n" ?>
2+
3+
// generated by `make:user:msgphp`
4+
// this configuration may be merged into your existing application configuration
5+
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7+
use function Symfony\Component\DependencyInjection\Loader\Configurator\ref;
8+
9+
return function (ContainerConfigurator $container) {
10+
<?php if ($config): ?>
11+
$container->extension('msgphp_user', <?= $config ?>);
12+
13+
<?php endif; ?>
14+
<?php if($services): ?>
15+
$container->services()
16+
->defaults()
17+
->private()
18+
->autoconfigure()
19+
->autowire()
20+
21+
<?php foreach ($services as $service): ?>
22+
<?= str_replace("\n", "\n ", $service)."\n" ?>
23+
<?php endforeach; ?>
24+
;
25+
<?php endif; ?>
26+
};

‎src/UserBundle/Resources/skeleton/controller/ForgotPasswordController.php‎

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?= "<?php\n" ?>
2+
3+
declare(strict_types=1);
4+
5+
namespace <?= $controller_ns ?>;
6+
7+
use <?= $user_class ?>;
8+
use <?= $form_ns ?>\ForgotPasswordType;
9+
use MsgPhp\User\Command\RequestUserPassword;
10+
use Symfony\Component\Form\FormFactoryInterface;
11+
use Symfony\Component\HttpFoundation\Request;
12+
use Symfony\Component\HttpFoundation\RedirectResponse;
13+
use Symfony\Component\HttpFoundation\Response;
14+
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
15+
use Symfony\Component\Messenger\MessageBusInterface;
16+
use Symfony\Component\Routing\Annotation\Route;
17+
use Twig\Environment;
18+
19+
/**
20+
* @Route("/forgot-password", name="forgot_password")
21+
*/
22+
final class ForgotPasswordController
23+
{
24+
public function __invoke(
25+
Request $request,
26+
FormFactoryInterface $formFactory,
27+
FlashBagInterface $flashBag,
28+
Environment $twig,
29+
MessageBusInterface $bus
30+
): Response {
31+
$form = $formFactory->createNamed('', ForgotPasswordType::class);
32+
$form->handleRequest($request);
33+
34+
if ($form->isSubmitted() && $form->isValid()) {
35+
/** @var <?= $user_short_class ?> $user */
36+
$user = $form->getData()['user'];
37+
$bus->dispatch(new RequestUserPassword($user->getId()));
38+
$flashBag->add('success', 'You\'re password is requested.');
39+
40+
return new RedirectResponse('/login');
41+
}
42+
43+
return new Response($twig->render('<?= $template_dir ?>forgot_password.html.twig', [
44+
'form' => $form->createView(),
45+
]));
46+
}
47+
}

‎src/UserBundle/Resources/skeleton/controller/LoginController.php‎

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?= "<?php\n" ?>
2+
3+
declare(strict_types=1);
4+
5+
namespace <?= $controller_ns ?>;
6+
7+
use <?= $form_ns ?>\LoginType;
8+
use Symfony\Component\Form\FormError;
9+
use Symfony\Component\Form\FormFactoryInterface;
10+
use Symfony\Component\HttpFoundation\Response;
11+
use Symfony\Component\Routing\Annotation\Route;
12+
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
13+
use Twig\Environment;
14+
15+
/**
16+
* @Route("/login", name="login")
17+
*/
18+
final class LoginController
19+
{
20+
public function __invoke(
21+
Environment $twig,
22+
FormFactoryInterface $formFactory,
23+
AuthenticationUtils $authenticationUtils
24+
): Response {
25+
$form = $formFactory->createNamed('', LoginType::class, [
26+
'<?= $username_field ?>' => $authenticationUtils->getLastUsername(),
27+
]);
28+
29+
if (null !== $error = $authenticationUtils->getLastAuthenticationError(true)) {
30+
$form->addError(new FormError($error->getMessage(), $error->getMessageKey(), $error->getMessageData()));
31+
}
32+
33+
return new Response($twig->render('<?= $template_dir ?>login.html.twig', [
34+
'form' => $form->createView(),
35+
]));
36+
}
37+
}

0 commit comments

Comments
 (0)