[DoctrineBundle] Fix bug in Auto Proxy Generation introduced with config merge refactoring. Use array_reverse() for $configs to fix incremental merge algorithm assumptions.
This commit is contained in:
parent
571448b047
commit
1bc0b54411
8
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
Normal file → Executable file
8
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
Normal file → Executable file
@ -66,6 +66,8 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
*/
|
||||
protected function mergeDbalConfig(array $configs, $container)
|
||||
{
|
||||
$configs = array_reverse($configs);
|
||||
|
||||
$supportedConnectionParams = array(
|
||||
'dbname' => 'dbname',
|
||||
'host' => 'host',
|
||||
@ -214,6 +216,8 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
*/
|
||||
public function ormLoad(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configs = array_reverse($configs);
|
||||
|
||||
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
|
||||
$loader->load('orm.xml');
|
||||
|
||||
@ -281,10 +285,10 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
$mergedConfig['default_connection'] = $config['default_connection'];
|
||||
}
|
||||
if (isset($config['auto_generate_proxy_classes'])) {
|
||||
$mergedConfig['auto_generate_proxy_classes'] = $config['auto_generate_proxy_classes'];
|
||||
$defaultManagerOptions['auto_generate_proxy_classes'] = $config['auto_generate_proxy_classes'];
|
||||
}
|
||||
if (isset($config['auto-generate-proxy-classes'])) {
|
||||
$mergedConfig['auto_generate_proxy_classes'] = $config['auto-generate-proxy-classes'];
|
||||
$defaultManagerOptions['auto_generate_proxy_classes'] = $config['auto-generate-proxy-classes'];
|
||||
}
|
||||
}
|
||||
$defaultManagerOptions['connection'] = $mergedConfig['default_connection'];
|
||||
|
16
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Normal file → Executable file
16
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Normal file → Executable file
@ -424,33 +424,33 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function testMultipleOrmLoadCalls()
|
||||
public function testOrmMergeConfigs()
|
||||
{
|
||||
$container = $this->getContainer(array('XmlBundle', 'AnnotationsBundle'));
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->dbalLoad(array(array()), $container);
|
||||
$loader->ormLoad(array(array(
|
||||
'auto_generate_proxy_dir' => true,
|
||||
'auto_generate_proxy_classes' => true,
|
||||
'mappings' => array('AnnotationsBundle' => array())
|
||||
),
|
||||
array(
|
||||
'auto_generate_proxy_dir' => false,
|
||||
'auto_generate_proxy_classes' => false,
|
||||
'mappings' => array('XmlBundle' => array())
|
||||
)), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_annotation_metadata_driver'),
|
||||
'DoctrineBundle\Tests\DependencyInjection\Fixtures\Bundles\AnnotationsBundle\Entity'
|
||||
));
|
||||
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_xml_metadata_driver'),
|
||||
'DoctrineBundle\Tests\DependencyInjection\Fixtures\Bundles\XmlBundle\Entity'
|
||||
));
|
||||
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_annotation_metadata_driver'),
|
||||
'DoctrineBundle\Tests\DependencyInjection\Fixtures\Bundles\AnnotationsBundle\Entity'
|
||||
));
|
||||
|
||||
$configDef = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array(false));
|
||||
$this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array(true));
|
||||
}
|
||||
|
||||
public function testEntityManagerMetadataCacheDriverConfiguration()
|
||||
|
Reference in New Issue
Block a user