|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AerialShip\SamlSPBundle; |
|
4
|
|
|
|
|
5
|
|
|
use AerialShip\SamlSPBundle\DependencyInjection\Security\Factory\SamlSpFactory; |
|
6
|
|
|
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; |
|
7
|
|
|
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass; |
|
8
|
|
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
10
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
11
|
|
|
|
|
12
|
|
|
class AerialShipSamlSPBundle extends Bundle |
|
13
|
|
|
{ |
|
14
|
|
|
public function build(ContainerBuilder $container) |
|
15
|
|
|
{ |
|
16
|
|
|
parent::build($container); |
|
17
|
|
|
|
|
18
|
|
|
/** @var $extension SecurityExtension */ |
|
19
|
|
|
$extension = $container->getExtension('security'); |
|
20
|
|
|
$extension->addSecurityListenerFactory(new SamlSpFactory()); |
|
21
|
|
|
|
|
22
|
|
|
$this->addRegisterMappingsPass($container); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param ContainerBuilder $container |
|
27
|
|
|
*/ |
|
28
|
|
|
private function addRegisterMappingsPass(ContainerBuilder $container) |
|
29
|
|
|
{ |
|
30
|
|
|
if (false === class_exists('Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass')) { |
|
31
|
|
|
throw new \LogicException('Missing RegisterMappingsPass available since symfony 2.3'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
$mappings = array(realpath(__DIR__ . '/Resources/config/doctrine-mapping') => 'AerialShip\SamlSPBundle\Model',); |
|
35
|
|
|
|
|
36
|
|
|
if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) { |
|
37
|
|
|
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, array('aerial_ship_saml_sp.model_manager_name'), 'aerial_ship_saml_sp.backend_type_orm')); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
if (class_exists('Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass')) { |
|
41
|
|
|
$container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, array('aerial_ship_saml_sp.model_manager_name'), 'aerial_ship_saml_sp.backend_type_mongodb')); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|