-
Notifications
You must be signed in to change notification settings - Fork 63
/
SymfonyCastsResetPasswordExtension.php
50 lines (41 loc) · 1.97 KB
/
SymfonyCastsResetPasswordExtension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/*
* This file is part of the SymfonyCasts ResetPasswordBundle package.
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SymfonyCasts\Bundle\ResetPassword\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
/**
* @author Jesse Rushlow <jr@rushlow.dev>
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
final class SymfonyCastsResetPasswordExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('reset_password_services.xml');
$configuration = $this->getConfiguration($configs, $container);
if (!$configuration) {
throw new \Exception('Configuration is not expected to be null');
}
$config = $this->processConfiguration($configuration, $configs);
$helperDefinition = $container->getDefinition('symfonycasts.reset_password.helper');
$helperDefinition->replaceArgument(2, new Reference($config['request_password_repository']));
$helperDefinition->replaceArgument(3, $config['lifetime']);
$helperDefinition->replaceArgument(4, $config['throttle_limit']);
$cleanerDefinition = $container->getDefinition('symfonycasts.reset_password.cleaner');
$cleanerDefinition->replaceArgument(0, new Reference($config['request_password_repository']));
$cleanerDefinition->replaceArgument(1, $config['enable_garbage_collection']);
}
public function getAlias(): string
{
return 'symfonycasts_reset_password';
}
}