1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoL\LdapBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* This is the class that loads and manages your bundle configuration. |
12
|
|
|
* |
13
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
14
|
|
|
* |
15
|
|
|
* @author DarwinOnLine |
16
|
|
|
* @author Maks3w |
17
|
|
|
* |
18
|
|
|
* @see https://github.com/DarwinOnLine/DoLLdapBundle |
19
|
|
|
*/ |
20
|
|
|
class DoLLdapExtension extends Extension |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
6 |
|
public function load(array $configs, ContainerBuilder $container) |
26
|
|
|
{ |
27
|
6 |
|
$configuration = new Configuration(); |
28
|
6 |
|
$config = $this->processConfiguration($configuration, $configs); |
29
|
|
|
|
30
|
5 |
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
31
|
5 |
|
foreach (array('services', 'security', 'validator', 'ldap_driver') as $basename) { |
32
|
5 |
|
$loader->load(sprintf('%s.yml', $basename)); |
33
|
5 |
|
} |
34
|
|
|
|
35
|
5 |
|
$container->setAlias('dol_ldap.user_hydrator', $config['service']['user_hydrator']); |
36
|
5 |
|
$container->setAlias('dol_ldap.ldap_manager', $config['service']['ldap_manager']); |
37
|
5 |
|
$container->setAlias('dol_ldap.ldap_driver', $config['service']['ldap_driver']); |
38
|
|
|
|
39
|
5 |
|
foreach ($config['domains'] as &$domain) { |
40
|
5 |
|
if (!isset($domain['driver']['baseDn'])) { |
41
|
1 |
|
$domain['driver']['baseDn'] = $domain['user']['baseDn']; |
42
|
1 |
|
} |
43
|
5 |
|
if (!isset($domain['driver']['accountFilterFormat'])) { |
44
|
1 |
|
$domain['driver']['accountFilterFormat'] = $domain['user']['filter']; |
45
|
1 |
|
} |
46
|
5 |
|
} |
47
|
|
|
|
48
|
5 |
|
$container->setParameter('dol_ldap.domains.parameters', $config['domains']); |
49
|
5 |
|
} |
50
|
|
|
|
51
|
1 |
|
public function getNamespace() |
52
|
|
|
{ |
53
|
1 |
|
return 'dol_ldap'; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|