Skip to content

Commit 23c7cb4

Browse files
authored
minor #312 use new bundle structure
1 parent b15e3a1 commit 23c7cb4

27 files changed

+44
-108
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/DependencyInjection/SymfonyCastsResetPasswordExtension.php

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/SymfonyCastsResetPasswordBundle.php

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,57 @@
99

1010
namespace SymfonyCasts\Bundle\ResetPassword;
1111

12-
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
13-
use Symfony\Component\HttpKernel\Bundle\Bundle;
14-
use SymfonyCasts\Bundle\ResetPassword\DependencyInjection\SymfonyCastsResetPasswordExtension;
12+
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
13+
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
15+
use Symfony\Component\DependencyInjection\Reference;
16+
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
1517

1618
/**
1719
* @author Jesse Rushlow <jr@rushlow.dev>
1820
* @author Ryan Weaver <ryan@symfonycasts.com>
1921
*/
20-
class SymfonyCastsResetPasswordBundle extends Bundle
22+
class SymfonyCastsResetPasswordBundle extends AbstractBundle
2123
{
22-
public function getContainerExtension(): ?ExtensionInterface
24+
protected string $extensionAlias = 'symfonycasts_reset_password';
25+
26+
public function configure(DefinitionConfigurator $definition): void
27+
{
28+
$definition->rootNode() /** @phpstan-ignore method.notFound */
29+
->children()
30+
->scalarNode('request_password_repository')
31+
->isRequired()
32+
->info('A class that implements ResetPasswordRequestRepositoryInterface - usually your ResetPasswordRequestRepository.')
33+
->end()
34+
->integerNode('lifetime')
35+
->defaultValue(3600)
36+
->info('The length of time in seconds that a password reset request is valid for after it is created.')
37+
->end()
38+
->integerNode('throttle_limit')
39+
->defaultValue(3600)
40+
->info('Another password reset cannot be made faster than this throttle time in seconds.')
41+
->end()
42+
->booleanNode('enable_garbage_collection')
43+
->defaultValue(true)
44+
->info('Enable/Disable automatic garbage collection.')
45+
->end()
46+
->end()
47+
;
48+
}
49+
50+
/** @param array<string, string|int|bool> $config */
51+
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
2352
{
24-
if (null === $this->extension) {
25-
$this->extension = new SymfonyCastsResetPasswordExtension();
26-
}
53+
$container->import('../config/reset_password_services.xml');
2754

28-
return $this->extension ?: null;
55+
$container->services()
56+
->get('symfonycasts.reset_password.helper')
57+
->arg(2, new Reference((string) $config['request_password_repository']))
58+
->arg(3, $config['lifetime'])
59+
->arg(4, $config['throttle_limit'])
60+
->get('symfonycasts.reset_password.cleaner')
61+
->arg(0, new Reference((string) $config['request_password_repository']))
62+
->arg(1, $config['enable_garbage_collection'])
63+
;
2964
}
3065
}

0 commit comments

Comments
 (0)