1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Guarded Authentication package. |
4
|
|
|
* |
5
|
|
|
* (c) Jafar Jabr <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Jafar\Bundle\GuardedAuthenticationBundle\DependencyInjection; |
12
|
|
|
|
13
|
|
|
use Exception; |
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class JafarGuardedAuthenticationExtension. |
21
|
|
|
* |
22
|
|
|
* @author Jafar Jabr <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class JafarGuardedAuthenticationExtension extends Extension |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @param array $configs |
28
|
|
|
* @param ContainerBuilder $container |
29
|
|
|
* |
30
|
|
|
* @throws Exception |
31
|
|
|
*/ |
32
|
|
|
public function load(array $configs, ContainerBuilder $container) |
33
|
|
|
{ |
34
|
|
|
$configuration = new Configuration(); |
35
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
36
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
37
|
|
|
|
38
|
|
|
try { |
39
|
|
|
$loader->load('services.yml'); |
40
|
|
|
} catch (Exception $e) { |
41
|
|
|
throw new Exception($e); |
42
|
|
|
} |
43
|
|
|
$container->setParameter('jafar_guarded_authentication.pass_phrase', $config['pass_phrase'] ?? ''); |
44
|
|
|
$container->setParameter('jafar_guarded_authentication.token_ttl', $config['token_ttl'] ?? 3600); |
45
|
|
|
$container->setParameter('jafar_guarded_authentication.login_route', $config['login_route'] ?? ''); |
46
|
|
|
$container->setParameter('jafar_guarded_authentication.home_page_route', $config['home_page_route'] ?? ''); |
47
|
|
|
$container->setParameter('jafar_guarded_authentication.api_login_route', $config['api_login_route'] ?? ''); |
48
|
|
|
$container->setParameter( |
49
|
|
|
'jafar_guarded_authentication.api_home_page_route', |
50
|
|
|
$config['api_home_page_route'] ?? '' |
51
|
|
|
); |
52
|
|
|
$container->setParameter('jafar_guarded_authentication.refresh_ttl', $config['refresh_ttl'] ?? 604800); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|