|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the LdapToolsBundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Chad Sikorra <[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 LdapTools\Bundle\LdapToolsBundle; |
|
12
|
|
|
|
|
13
|
|
|
use LdapTools\Bundle\LdapToolsBundle\DependencyInjection\Compiler\EventRegisterPass; |
|
14
|
|
|
use LdapTools\Bundle\LdapToolsBundle\DependencyInjection\Compiler\LdifUrlLoaderPass; |
|
15
|
|
|
use LdapTools\Bundle\LdapToolsBundle\DependencyInjection\Security\Factory\LdapFormLoginFactory; |
|
16
|
|
|
use LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectCollectionType; |
|
17
|
|
|
use LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectType; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
19
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
20
|
|
|
use Doctrine\DBAL\Types\Type; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The Bundle class. |
|
24
|
|
|
* |
|
25
|
|
|
* @author Chad Sikorra <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class LdapToolsBundle extends Bundle |
|
28
|
|
|
{ |
|
29
|
|
|
public function __construct() |
|
30
|
|
|
{ |
|
31
|
|
|
// It's useful to auto-register the types, but we should not assume they are using doctrine... |
|
32
|
|
|
if (!class_exists('\Doctrine\DBAL\Types\Type')) { |
|
33
|
|
|
return; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
if (!Type::hasType(LdapObjectType::TYPE)) { |
|
37
|
|
|
Type::addType( |
|
38
|
|
|
LdapObjectType::TYPE, |
|
39
|
|
|
'\LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectType' |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
if (!Type::hasType(LdapObjectCollectionType::TYPE)) { |
|
43
|
|
|
Type::addType( |
|
44
|
|
|
LdapObjectCollectionType::TYPE, |
|
45
|
|
|
'\LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectCollectionType' |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Make Symfony aware of the LDAP listener factory and add the compiler pass. |
|
52
|
|
|
* |
|
53
|
|
|
* @param ContainerBuilder $container |
|
54
|
|
|
*/ |
|
55
|
|
|
public function build(ContainerBuilder $container) |
|
56
|
|
|
{ |
|
57
|
|
|
parent::build($container); |
|
58
|
|
|
$extension = $container->getExtension('security'); |
|
59
|
|
|
$extension->addSecurityListenerFactory(new LdapFormLoginFactory()); |
|
60
|
|
|
$container->addCompilerPass(new EventRegisterPass()); |
|
61
|
|
|
$container->addCompilerPass(new LdifUrlLoaderPass()); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|