Skip to content

Commit

Permalink
[DoctrineBundle] updated to only load default settings once
Browse files Browse the repository at this point in the history
Fixed a bug that caused DoctrineBundle to load default settings for
every parsed config file rather than just the first.  This caused
imported files to be override by default values.
  • Loading branch information
Brandon Turner authored and fabpot committed Aug 4, 2010
1 parent b9199cb commit a3fc1be
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ protected function createOrmProxyDirectory()
*/
protected function loadOrmDefaults(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['orm']);
if (!$container->hasDefinition('doctrine.orm.metadata_driver.annotation')) {
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['orm']);
}

// Allow these application configuration options to override the defaults
$options = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,25 @@ public function testEntityManagerMemcacheMetadataCacheDriverConfiguration()
$this->assertEquals(11211, $calls[0][1][1]);
}

public function testDependencyInjectionImportsOverrideDefaults()
{
$container = new ContainerBuilder();
$loader = $this->getDoctrineExtensionLoader();
$container->registerExtension($loader);

$this->loadFromFile($container, 'orm_imports');

$container->freeze();

$this->assertEquals('apc', $container->getParameter('doctrine.orm.metadata_cache_driver'));
$this->assertTrue($container->getParameter('doctrine.orm.auto_generate_proxy_classes'));
}

protected function getDoctrineExtensionLoader($bundle = 'YamlBundle')
{
require_once __DIR__.'/Fixtures/Bundles/'.$bundle.'/'.$bundle.'.php';
$bundleDirs = array('Fixtures\\Bundles' => __DIR__.'/Fixtures/Bundles');
$bundles = array('Fixtures\\Bundles\\'.$bundle.'\\'.$bundle);
return new DoctrineExtension($bundleDirs, $bundles, sys_get_temp_dir());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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"
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/orm http://www.symfony-project.org/schema/dic/doctrine/orm/doctrine-1.0.xsd
http://www.symfony-project.org/schema/dic/doctrine/dbal http://www.symfony-project.org/schema/dic/doctrine/dbal/doctrine-1.0.xsd">

<imports>
<import resource="orm_imports_import.xml" />
</imports>

<doctrine:orm
auto_generate_proxy_classes="true"
>
</doctrine:orm>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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"
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/orm http://www.symfony-project.org/schema/dic/doctrine/orm/doctrine-1.0.xsd
http://www.symfony-project.org/schema/dic/doctrine/dbal http://www.symfony-project.org/schema/dic/doctrine/dbal/doctrine-1.0.xsd">

<doctrine:orm
auto_generate_proxy_classes="false"
metadata_cache_driver="apc"
>
</doctrine:orm>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

imports:
- { resource: orm_imports_import.yml }

doctrine.orm:
auto_generate_proxy_classes: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

doctrine.orm:
auto_generate_proxy_classes: false
metadata_cache_driver: apc

0 comments on commit a3fc1be

Please sign in to comment.