[DoctrineMongoDBBundle] updated to only load default settings once
Fixed a bug that caused DoctrineMongoDBBundle to load default settings for every parsed config file rather than just the first. This caused imported files to be override by default values.
This commit is contained in:
parent
a3fc1be13f
commit
c9001f37fc
@ -74,9 +74,12 @@ class MongoDBExtension extends Extension
|
||||
*/
|
||||
protected function loadDefaults(array $config, ContainerBuilder $container)
|
||||
{
|
||||
// Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
|
||||
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
|
||||
$loader->load($this->resources['mongodb']);
|
||||
if(!$container->hasDefinition('doctrine.odm.mongodb.metadata.annotation'))
|
||||
{
|
||||
// Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
|
||||
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
|
||||
$loader->load($this->resources['mongodb']);
|
||||
}
|
||||
|
||||
// Allow these application configuration options to override the defaults
|
||||
$options = array(
|
||||
|
@ -295,6 +295,20 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
|
||||
$this->assertEquals(11211, $calls[0][1][1]);
|
||||
}
|
||||
|
||||
public function testDependencyInjectionImportsOverrideDefaults()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = $this->getMongoDbExtensionLoader();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'odm_imports');
|
||||
|
||||
$container->freeze();
|
||||
|
||||
$this->assertEquals('apc', $container->getParameter('doctrine.odm.mongodb.metadata_cache_driver'));
|
||||
$this->assertTrue($container->getParameter('doctrine.odm.mongodb.auto_generate_proxy_classes'));
|
||||
}
|
||||
|
||||
protected function getMongoDbExtensionLoader($bundle = 'YamlBundle')
|
||||
{
|
||||
require_once __DIR__.'/Fixtures/Bundles/'.$bundle.'/'.$bundle.'.php';
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://www.symfony-project.org/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:doctrine="http://www.symfony-project.org/schema/dic/doctrine/odm/mongodb"
|
||||
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd
|
||||
http://www.symfony-project.org/schema/dic/doctrine/odm/mongodb http://www.symfony-project.org/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
|
||||
|
||||
<imports>
|
||||
<import resource="odm_imports_import.xml" />
|
||||
</imports>
|
||||
|
||||
<doctrine:mongodb
|
||||
auto_generate_proxy_classes="true"
|
||||
>
|
||||
</doctrine:mongodb>
|
||||
</container>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://www.symfony-project.org/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:doctrine="http://www.symfony-project.org/schema/dic/doctrine/odm/mongodb"
|
||||
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd
|
||||
http://www.symfony-project.org/schema/dic/doctrine/odm/mongodb http://www.symfony-project.org/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
|
||||
|
||||
<doctrine:mongodb
|
||||
auto_generate_proxy_classes="false"
|
||||
metadata_cache_driver="apc"
|
||||
>
|
||||
</doctrine:mongodb>
|
||||
</container>
|
@ -0,0 +1,5 @@
|
||||
imports:
|
||||
- { resource: odm_imports_import.yml }
|
||||
|
||||
doctrine_odm.mongodb:
|
||||
auto_generate_proxy_classes: true
|
@ -0,0 +1,3 @@
|
||||
doctrine_odm.mongodb:
|
||||
auto_generate_proxy_classes: false
|
||||
metadata_cache_driver: apc
|
Reference in New Issue
Block a user