|
9 | 9 |
|
10 | 10 | namespace SymfonyCasts\Bundle\ResetPassword;
|
11 | 11 |
|
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; |
15 | 17 |
|
16 | 18 | /**
|
17 | 19 | * @author Jesse Rushlow <jr@rushlow.dev>
|
18 | 20 | * @author Ryan Weaver <ryan@symfonycasts.com>
|
19 | 21 | */
|
20 |
| -class SymfonyCastsResetPasswordBundle extends Bundle |
| 22 | +class SymfonyCastsResetPasswordBundle extends AbstractBundle |
21 | 23 | {
|
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 |
23 | 52 | {
|
24 |
| - if (null === $this->extension) { |
25 |
| - $this->extension = new SymfonyCastsResetPasswordExtension(); |
26 |
| - } |
| 53 | + $container->import('../config/reset_password_services.xml'); |
27 | 54 |
|
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 | + ; |
29 | 64 | }
|
30 | 65 | }
|
0 commit comments