This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathBazingaOAuthServerBundle.php
61 lines (50 loc) · 2.48 KB
/
BazingaOAuthServerBundle.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
namespace Bazinga\OAuthServerBundle;
use Bazinga\OAuthServerBundle\DependencyInjection\BazingaOAuthServerExtension;
use Bazinga\OAuthServerBundle\DependencyInjection\Compiler\AddSignaturesPass;
use Bazinga\OAuthServerBundle\DependencyInjection\Compiler\RegisterMappingsPass;
use Bazinga\OAuthServerBundle\DependencyInjection\Security\Factory\OAuthFactory;
use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* @author William DURAND <william.durand1@gmail.com>
*/
class BazingaOAuthServerBundle extends Bundle
{
/**
* Constructor
*/
public function __construct()
{
$this->extension = new BazingaOAuthServerExtension();
}
/**
* {@inheritDoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new AddSignaturesPass());
$extension = $container->getExtension('security');
$extension->addSecurityListenerFactory(new OAuthFactory());
$this->addRegisterMappingsPass($container);
}
private function addRegisterMappingsPass(ContainerBuilder $container)
{
$mappings = array(
realpath(__DIR__ . '/Resources/config/model') => 'Bazinga\OAuthServerBundle\Model',
);
if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, array('bazinga.oauth.model_manager_name'), 'bazinga.oauth.backend_type_orm'));
}
if (class_exists('Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass')) {
$container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, array('bazinga.oauth.model_manager_name'), 'bazinga.oauth.backend_type_mongodb'));
}
if (class_exists('Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass')) {
$container->addCompilerPass(DoctrineCouchDBMappingsPass::createXmlMappingDriver($mappings, array('bazinga.oauth.model_manager_name'), 'bazinga.oauth.backend_type_couchdb'));
}
}
}