|
1
|
|
|
<?php |
|
2
|
|
|
namespace TwoMartens\Bundle\CoreBundle; |
|
3
|
|
|
|
|
4
|
|
|
use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass; |
|
5
|
|
|
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; |
|
6
|
|
|
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
8
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
9
|
|
|
use TwoMartens\Bundle\CoreBundle\DependencyInjection\Compiler\ValidationPass; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Bundle class for 2WP Core Bundle. |
|
13
|
|
|
* |
|
14
|
|
|
* @author Jim Martens <[email protected]> |
|
15
|
|
|
* @copyright 2013-2015 Jim Martens |
|
16
|
|
|
* @license http://www.gnu.org/licenses/lgpl-3.0 GNU Lesser General Public License, version 3 |
|
17
|
|
|
*/ |
|
18
|
|
|
class TwoMartensCoreBundle extends Bundle |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @param ContainerBuilder $container |
|
22
|
|
|
*/ |
|
23
|
|
|
public function build(ContainerBuilder $container) |
|
24
|
|
|
{ |
|
25
|
|
|
parent::build($container); |
|
26
|
|
|
$container->addCompilerPass(new ValidationPass()); |
|
27
|
|
|
|
|
28
|
|
|
$this->addRegisterMappingsPass($container); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param ContainerBuilder $container |
|
33
|
|
|
*/ |
|
34
|
|
|
private function addRegisterMappingsPass(ContainerBuilder $container) |
|
35
|
|
|
{ |
|
36
|
|
|
// the base class is only available since symfony 2.3 |
|
37
|
|
|
$symfonyVersion = class_exists('Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass'); |
|
38
|
|
|
|
|
39
|
|
|
$mappings = array( |
|
40
|
|
|
realpath(__DIR__ . '/Resources/config/doctrine/model') => 'TwoMartens\Bundle\CoreBundle\Model', |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
if ($symfonyVersion && |
|
44
|
|
|
class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) { |
|
45
|
|
|
$container->addCompilerPass( |
|
46
|
|
|
DoctrineOrmMappingsPass::createXmlMappingDriver( |
|
47
|
|
|
$mappings, |
|
48
|
|
|
array(), |
|
49
|
|
|
'twomartens.core.backend_type_orm', |
|
50
|
|
|
array('TwoMartensCoreBundle' => 'TwoMartens\Bundle\CoreBundle\Model') |
|
51
|
|
|
) |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
if ($symfonyVersion && |
|
56
|
|
|
class_exists('Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass')) { |
|
57
|
|
|
$container->addCompilerPass( |
|
58
|
|
|
DoctrineMongoDBMappingsPass::createXmlMappingDriver( |
|
59
|
|
|
$mappings, |
|
60
|
|
|
array(), |
|
61
|
|
|
'twomartens.core.backend_type_mongodb', |
|
62
|
|
|
array('TwoMartensCoreBundle' => 'TwoMartens\Bundle\CoreBundle\Model') |
|
63
|
|
|
) |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if ($symfonyVersion && |
|
68
|
|
|
class_exists('Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass')) { |
|
69
|
|
|
$container->addCompilerPass( |
|
70
|
|
|
DoctrineCouchDBMappingsPass::createXmlMappingDriver( |
|
71
|
|
|
$mappings, |
|
72
|
|
|
array(), |
|
73
|
|
|
'twomartens.core.backend_type_couchdb', |
|
74
|
|
|
array('TwoMartensCoreBundle' => 'TwoMartens\Bundle\CoreBundle\Model') |
|
75
|
|
|
) |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|