-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathLdapToolsBundle.php
63 lines (58 loc) · 2.13 KB
/
LdapToolsBundle.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
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* This file is part of the LdapToolsBundle package.
*
* (c) Chad Sikorra <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace LdapTools\Bundle\LdapToolsBundle;
use LdapTools\Bundle\LdapToolsBundle\DependencyInjection\Compiler\EventRegisterPass;
use LdapTools\Bundle\LdapToolsBundle\DependencyInjection\Compiler\LdifUrlLoaderPass;
use LdapTools\Bundle\LdapToolsBundle\DependencyInjection\Security\Factory\LdapFormLoginFactory;
use LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectCollectionType;
use LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectType;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\DBAL\Types\Type;
/**
* The Bundle class.
*
* @author Chad Sikorra <[email protected]>
*/
class LdapToolsBundle extends Bundle
{
public function __construct()
{
// It's useful to auto-register the types, but we should not assume they are using doctrine...
if (!class_exists('\Doctrine\DBAL\Types\Type')) {
return;
}
if (!Type::hasType(LdapObjectType::TYPE)) {
Type::addType(
LdapObjectType::TYPE,
'\LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectType'
);
}
if (!Type::hasType(LdapObjectCollectionType::TYPE)) {
Type::addType(
LdapObjectCollectionType::TYPE,
'\LdapTools\Bundle\LdapToolsBundle\Doctrine\Type\LdapObjectCollectionType'
);
}
}
/**
* Make Symfony aware of the LDAP listener factory and add the compiler pass.
*
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$extension = $container->getExtension('security');
$extension->addSecurityListenerFactory(new LdapFormLoginFactory());
$container->addCompilerPass(new EventRegisterPass());
$container->addCompilerPass(new LdifUrlLoaderPass());
}
}