forked from hwi/HWIOAuthBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HWIOAuthBundle.php
61 lines (53 loc) · 1.81 KB
/
HWIOAuthBundle.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
<?php
/*
* This file is part of the HWIOAuthBundle package.
*
* (c) Hardware.Info <opensource@hardware.info>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace HWI\Bundle\OAuthBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle,
Symfony\Component\HttpKernel\Kernel,
Symfony\Component\DependencyInjection\ContainerBuilder;
use HWI\Bundle\OAuthBundle\DependencyInjection\HWIOAuthExtension,
HWI\Bundle\OAuthBundle\DependencyInjection\Security\Factory\OAuthFactory,
HWI\Bundle\OAuthBundle\Security\Core\UserProvider\EntityFactory;
/**
* HWIOAuthBundle
*
* @author Geoffrey Bachelet <geoffrey.bachelet@gmail.com>
* @author Alexander <geoffrey.bachelet@gmail.com>
*/
class HWIOAuthBundle extends Bundle
{
/**
* {@inheritDoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
// We can only register the security listener factory in sf2.1
// If you're using 2.0, import the security_factory.xml in your security.yml:
//
// factories:
// - "%kernel.root_dir%/../../vendor/bundles/HWI/Bundle/OAuthBundle/Resources/config/security_factory.xml"
if (version_compare(Kernel::VERSION, '2.1-DEV', '>=')) {
$extension = $container->getExtension('security');
$extension->addSecurityListenerFactory(new OAuthFactory());
}
}
/**
* {@inheritdoc}
*/
public function getContainerExtension()
{
// return the right extension instead of "auto-registering" it. Now the
// alias can be hwi_oauth instead of hwi_o_auth..
if (null === $this->extension) {
return new HWIOAuthExtension();
}
return $this->extension;
}
}