/
DoctrineOXMExtension.php
97 lines (78 loc) · 2.59 KB
/
DoctrineOXMExtension.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Doctrine\Bundle\OXMBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Bundle\DoctrineAbstractBundle\DependencyInjection\AbstractDoctrineExtension;
/**
* Doctrine OXM extension.
*
* @author Igor Golovanov <igor.golovanov@gmail.com>
*/
class DoctrineMongoDBExtension extends AbstractDoctrineExtension
{
/**
* Responds to the doctrine_mongodb configuration parameter.
*/
public function load(array $configs, ContainerBuilder $container)
{
// Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('oxm.xml');
// set some options as parameters and unset them
$config = $this->overrideParameters($config, $container);
}
/**
* Uses some of the extension options to override DI extension parameters.
*
* @param array $options The available configuration options
* @param ContainerBuilder $container A ContainerBuilder instance
*/
protected function overrideParameters($options, ContainerBuilder $container)
{
$overrides = array(
'proxy_namespace',
'proxy_dir',
'auto_generate_proxy_classes',
);
foreach ($overrides as $key) {
if (isset($options[$key])) {
$container->setParameter('doctrine.oxm.'.$key, $options[$key]);
// the option should not be used, the parameter should be referenced
unset($options[$key]);
}
}
return $options;
}
protected function getObjectManagerElementName($name)
{
return 'doctrine.oxm.' . $name;
}
protected function getMappingObjectDefaultName()
{
return 'XmlEntity';
}
protected function getMappingResourceConfigDirectory()
{
return 'Resources/config/doctrine';
}
protected function getMappingResourceExtension()
{
return 'oxm';
}
public function getAlias()
{
return 'doctrine_oxm';
}
/**
* @return string
*/
public function getXsdValidationBasePath()
{
return __DIR__.'/../Resources/config/schema';
}
}