|
@@ -135,9 +135,14 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
|
|
|
$defaultDatabase = isset($documentManager['default_database']) ? $documentManager['default_database'] : $container->getParameter('doctrine.odm.mongodb.default_database');
|
|
|
$proxyCacheDir = $container->getParameter('kernel.cache_dir').'/doctrine/odm/mongodb/Proxies';
|
|
|
$hydratorCacheDir = $container->getParameter('kernel.cache_dir').'/doctrine/odm/mongodb/Hydrators';
|
|
|
+ $configServiceName = sprintf('doctrine.odm.mongodb.%s_configuration', $documentManager['name']);
|
|
|
|
|
|
- $odmConfigDef = new Definition('%doctrine.odm.mongodb.configuration_class%');
|
|
|
- $container->setDefinition(sprintf('doctrine.odm.mongodb.%s_configuration', $documentManager['name']), $odmConfigDef);
|
|
|
+ if ($container->hasDefinition($configServiceName)) {
|
|
|
+ $odmConfigDef = $container->getDefinition($configServiceName);
|
|
|
+ } else {
|
|
|
+ $odmConfigDef = new Definition('%doctrine.odm.mongodb.configuration_class%');
|
|
|
+ $container->setDefinition($configServiceName, $odmConfigDef);
|
|
|
+ }
|
|
|
|
|
|
$this->loadDocumentManagerBundlesMappingInformation($documentManager, $odmConfigDef, $container);
|
|
|
$this->loadDocumentManagerMetadataCacheDriver($documentManager, $container);
|
|
@@ -155,6 +160,9 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
|
|
|
'setLoggerCallable' => array(new Reference('doctrine.odm.mongodb.logger'), 'logQuery'),
|
|
|
);
|
|
|
foreach ($methods as $method => $arg) {
|
|
|
+ if ($odmConfigDef->hasMethodCall($method)) {
|
|
|
+ $odmConfigDef->removeMethodCall($method);
|
|
|
+ }
|
|
|
$odmConfigDef->addMethodCall($method, array($arg));
|
|
|
}
|
|
|
|
|
@@ -308,7 +316,6 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
|
|
|
return $connections;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Loads an ODM document managers bundle mapping information.
|
|
|
*
|
|
@@ -338,7 +345,8 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
|
|
|
* In the case of bundles everything is really optional (which leads to autodetection for this bundle) but
|
|
|
* in the mappings key everything except alias is a required argument.
|
|
|
*
|
|
|
- * @param array $entityManager A configured ORM entity manager.
|
|
|
+ * @param array $documentManager A configured ODM entity manager.
|
|
|
+ * @param Definition A Definition instance
|
|
|
* @param ContainerBuilder $container A ContainerBuilder instance
|
|
|
*/
|
|
|
protected function loadDocumentManagerBundlesMappingInformation(array $documentManager, Definition $odmConfigDef, ContainerBuilder $container)
|
|
@@ -349,7 +357,17 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
|
|
|
|
|
|
$this->loadMappingInformation($documentManager, $container);
|
|
|
$this->registerMappingDrivers($documentManager, $container);
|
|
|
-
|
|
|
+
|
|
|
+ if ($odmConfigDef->hasMethodCall('setDocumentNamespaces')) {
|
|
|
+ // TODO: Can we make a method out of it on Definition? replaceMethodArguments() or something.
|
|
|
+ $calls = $odmConfigDef->getMethodCalls();
|
|
|
+ foreach ($calls AS $call) {
|
|
|
+ if ($call[0] == 'setDocumentNamespaces') {
|
|
|
+ $this->aliasMap = array_merge($call[1][0], $this->aliasMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $method = $odmConfigDef->removeMethodCall('setDocumentNamespaces');
|
|
|
+ }
|
|
|
$odmConfigDef->addMethodCall('setDocumentNamespaces', array($this->aliasMap));
|
|
|
}
|
|
|
|