diff --git a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php
index 977b1758e9cf..b6e60fd22984 100644
--- a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php
@@ -44,6 +44,10 @@ private function addDbalSection(NodeBuilder $node)
{
$node
->arrayNode('dbal')
+ ->beforeNormalization()
+ ->ifNull()
+ ->then(function($v) { return array (); }) // Let use the default values with the subsequent closure.
+ ->end()
->beforeNormalization()
->ifTrue(function($v){ return is_array($v) && !array_key_exists('connections', $v) && !array_key_exists('connection', $v); })
->then(function($v) {
@@ -61,7 +65,7 @@ private function addDbalSection(NodeBuilder $node)
return $v;
})
->end()
- ->scalarNode('default_connection')->cannotBeEmpty()->defaultValue('default')->end()
+ ->scalarNode('default_connection')->isRequired()->cannotBeEmpty()->end()
->fixXmlConfig('type')
->arrayNode('types')
->useAttributeAsKey('name')
@@ -82,6 +86,7 @@ private function getDbalConnectionsNode()
{
$node = new NodeBuilder('connections', 'array');
$node
+ ->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->prototype('array')
->scalarNode('dbname')->end()
@@ -132,8 +137,7 @@ private function addOrmSection(NodeBuilder $node)
return $v;
})
->end()
- ->scalarNode('default_entity_manager')->cannotBeEmpty()->defaultValue('default')->end()
- ->scalarNode('default_connection')->cannotBeEmpty()->defaultValue('default')->end()
+ ->scalarNode('default_entity_manager')->isRequired()->cannotBeEmpty()->end()
->booleanNode('auto_generate_proxy_classes')->defaultFalse()->end()
->scalarNode('proxy_dir')->defaultValue('%kernel.cache_dir%/doctrine/orm/Proxies')->end()
->scalarNode('proxy_namespace')->defaultValue('Proxies')->end()
@@ -147,6 +151,7 @@ private function getOrmEntityManagersNode()
{
$node = new NodeBuilder('entity_managers', 'array');
$node
+ ->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->prototype('array')
->addDefaultsIfNotSet()
@@ -157,6 +162,8 @@ private function getOrmEntityManagersNode()
->scalarNode('class_metadata_factory_name')->defaultValue('%doctrine.orm.class_metadata_factory_name%')->end()
->fixXmlConfig('mapping')
->arrayNode('mappings')
+ ->isRequired()
+ ->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->prototype('array')
->beforeNormalization()
diff --git a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
index 7d38f147f65d..df3694f2b145 100755
--- a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
+++ b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
@@ -140,8 +140,7 @@ protected function ormLoad(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('orm.xml');
-
- $options = array('default_entity_manager', 'default_connection', 'auto_generate_proxy_classes', 'proxy_dir', 'proxy_namespace');
+ $options = array('default_entity_manager', 'auto_generate_proxy_classes', 'proxy_dir', 'proxy_namespace');
foreach ($options as $key) {
$container->setParameter('doctrine.orm.'.$key, $config[$key]);
}
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
index 0a2e1abba759..9d2290d7249c 100755
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
@@ -186,7 +186,7 @@ public function testSingleEntityManagerConfiguration()
$container = $this->getContainer();
$loader = new DoctrineExtension();
- $loader->load(array(array('dbal' => array(), 'orm' => array())), $container);
+ $loader->load(array(array('dbal' => array(), 'orm' => array('mappings' => array('YamlBundle' => array())))), $container);
$definition = $container->getDefinition('doctrine.dbal.default_connection');
$this->assertEquals('Doctrine\DBAL\Connection', $definition->getClass());
@@ -208,8 +208,6 @@ public function testLoadSimpleSingleConnection()
$loader = new DoctrineExtension();
$container->registerExtension($loader);
- $loader->load(array(array('dbal' => array(), 'orm' => array())), $container);
-
$this->loadFromFile($container, 'orm_service_simple_single_entity_manager');
$container->getCompilerPassConfig()->setOptimizationPasses(array());
@@ -269,6 +267,8 @@ public function testLoadSingleConnection()
'password' => 'sqlite_s3cr3t',
'dbname' => 'sqlite_db',
'memory' => true,
+ 'logging' => false,
+ 'charset' => 'UTF-8'
),
new Reference('doctrine.dbal.default_connection.configuration'),
new Reference('doctrine.dbal.default_connection.event_manager')
@@ -307,9 +307,9 @@ public function testLoadMultipleConnections()
$this->assertEquals('doctrine.dbal.conn1_connection.configuration', (string) $args[1]);
$this->assertEquals('doctrine.dbal.conn1_connection.event_manager', (string) $args[2]);
- $this->assertEquals('doctrine.orm.dm2_entity_manager', (string) $container->getAlias('doctrine.orm.entity_manager'));
+ $this->assertEquals('doctrine.orm.em2_entity_manager', (string) $container->getAlias('doctrine.orm.entity_manager'));
- $definition = $container->getDefinition('doctrine.orm.dm1_entity_manager');
+ $definition = $container->getDefinition('doctrine.orm.em1_entity_manager');
$this->assertEquals('%doctrine.orm.entity_manager_class%', $definition->getClass());
$this->assertEquals('%doctrine.orm.entity_manager_class%', $definition->getFactoryClass());
$this->assertEquals('create', $definition->getFactoryMethod());
@@ -319,7 +319,7 @@ public function testLoadMultipleConnections()
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.dbal.conn1_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
- $this->assertEquals('doctrine.orm.dm1_configuration', (string) $arguments[1]);
+ $this->assertEquals('doctrine.orm.em1_configuration', (string) $arguments[1]);
$definition = $container->getDefinition('doctrine.dbal.conn2_connection');
$this->assertEquals('Doctrine\DBAL\Connection', $definition->getClass());
@@ -331,7 +331,7 @@ public function testLoadMultipleConnections()
$this->assertEquals('doctrine.dbal.conn2_connection.configuration', (string) $args[1]);
$this->assertEquals('doctrine.dbal.conn2_connection.event_manager', (string) $args[2]);
- $definition = $container->getDefinition('doctrine.orm.dm2_entity_manager');
+ $definition = $container->getDefinition('doctrine.orm.em2_entity_manager');
$this->assertEquals('%doctrine.orm.entity_manager_class%', $definition->getClass());
$this->assertEquals('%doctrine.orm.entity_manager_class%', $definition->getFactoryClass());
$this->assertEquals('create', $definition->getFactoryMethod());
@@ -341,15 +341,15 @@ public function testLoadMultipleConnections()
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.dbal.conn2_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
- $this->assertEquals('doctrine.orm.dm2_configuration', (string) $arguments[1]);
+ $this->assertEquals('doctrine.orm.em2_configuration', (string) $arguments[1]);
- $definition = $container->getDefinition('doctrine.orm.dm1_metadata_cache');
+ $definition = $container->getDefinition('doctrine.orm.em1_metadata_cache');
$this->assertEquals('%doctrine.orm.cache.xcache_class%', $definition->getClass());
- $definition = $container->getDefinition('doctrine.orm.dm1_query_cache');
+ $definition = $container->getDefinition('doctrine.orm.em1_query_cache');
$this->assertEquals('%doctrine.orm.cache.array_class%', $definition->getClass());
- $definition = $container->getDefinition('doctrine.orm.dm1_result_cache');
+ $definition = $container->getDefinition('doctrine.orm.em1_result_cache');
$this->assertEquals('%doctrine.orm.cache.array_class%', $definition->getClass());
}
@@ -469,10 +469,10 @@ public function testEntityManagerMetadataCacheDriverConfiguration()
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
- $definition = $container->getDefinition('doctrine.orm.dm1_metadata_cache');
+ $definition = $container->getDefinition('doctrine.orm.em1_metadata_cache');
$this->assertDICDefinitionClass($definition, '%doctrine.orm.cache.xcache_class%');
- $definition = $container->getDefinition('doctrine.orm.dm2_metadata_cache');
+ $definition = $container->getDefinition('doctrine.orm.em2_metadata_cache');
$this->assertDICDefinitionClass($definition, '%doctrine.orm.cache.apc_class%');
}
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/dbal_service_multiple_connections.xml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/dbal_service_multiple_connections.xml
index 1f568e4691da..acfa896a4027 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/dbal_service_multiple_connections.xml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/dbal_service_multiple_connections.xml
@@ -7,7 +7,7 @@
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
-
+
-
+
-
+
+
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_imports_import.xml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_imports_import.xml
index e8f6e95fa5df..b8270feb268d 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_imports_import.xml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_imports_import.xml
@@ -10,6 +10,8 @@
+ >
+
+
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_multiple_em_bundle_mappings.xml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_multiple_em_bundle_mappings.xml
index 1e15c060d240..58569052ea4c 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_multiple_em_bundle_mappings.xml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_multiple_em_bundle_mappings.xml
@@ -7,7 +7,7 @@
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
-
+
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_multiple_entity_managers.xml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_multiple_entity_managers.xml
index 10f63c7c45a6..9c3b840c4ef0 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_multiple_entity_managers.xml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_multiple_entity_managers.xml
@@ -28,9 +28,13 @@
memory="true" />
-
-
-
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_simple_single_entity_manager.xml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_simple_single_entity_manager.xml
index 274b5801ef40..e79ab114cc8b 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_simple_single_entity_manager.xml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_simple_single_entity_manager.xml
@@ -15,6 +15,7 @@
11211
Memcache
+
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_single_entity_manager.xml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_single_entity_manager.xml
index fd12c386c860..d73955f9eeeb 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_single_entity_manager.xml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/xml/orm_service_single_entity_manager.xml
@@ -11,7 +11,7 @@
-
+
@@ -34,6 +32,7 @@
11211
Memcache
+
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_multiple_connections.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_multiple_connections.yml
index 491b2838b2bc..a01101d265e7 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_multiple_connections.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_multiple_connections.yml
@@ -1,5 +1,6 @@
doctrine:
dbal:
+ default_connection: mysql
connections:
mysql:
dbname: mysql_db
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_single_connection.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_single_connection.yml
index 60d093fe4bfe..1b15fc376e90 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_single_connection.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_service_single_connection.yml
@@ -1,5 +1,6 @@
doctrine:
dbal:
+ default_connection: mysql
connections:
mysql:
dbname: mysql_db
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_types.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_types.yml
index e0486ac64400..1e86dc462e4a 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_types.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/dbal_types.yml
@@ -1,4 +1,7 @@
doctrine:
dbal:
+ default_connection: default
types:
- test: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType
\ No newline at end of file
+ test: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType
+ connections:
+ default: ~
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_imports_import.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_imports_import.yml
index e0362aedf33b..3a7b5074943c 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_imports_import.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_imports_import.yml
@@ -2,3 +2,5 @@ doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver: apc
+ mappings:
+ YamlBundle: ~
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_multiple_em_bundle_mappings.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_multiple_em_bundle_mappings.yml
index bbaa01a33a2a..9e9c89add81d 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_multiple_em_bundle_mappings.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_multiple_em_bundle_mappings.yml
@@ -1,8 +1,7 @@
doctrine:
orm:
+ default_entity_manager: em2
entity_managers:
- default_entity_manager: dm2
- default_connection: conn1
em1:
mappings:
AnnotationsBundle: ~
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_multiple_entity_managers.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_multiple_entity_managers.yml
index 6a345b6b560c..31b9cc1aabcf 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_multiple_entity_managers.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_multiple_entity_managers.yml
@@ -3,6 +3,7 @@ parameters:
doctrine:
dbal:
+ default_connection: conn1
connections:
conn1:
driver: pdo_sqlite
@@ -18,13 +19,16 @@ doctrine:
memory: true
orm:
- default_entity_manager: dm2
- default_connection: conn1
+ default_entity_manager: em2
auto_generate_proxy_classes: true
entity_managers:
- dm1:
+ em1:
metadata_cache_driver: xcache
connection: conn1
- dm2:
+ mappings:
+ YamlBundle: ~
+ em2:
metadata_cache_driver: apc
connection: conn2
+ mappings:
+ YamlBundle: ~
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_simple_single_entity_manager.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_simple_single_entity_manager.yml
index 23572eb710da..94cde3fce1bf 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_simple_single_entity_manager.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_simple_single_entity_manager.yml
@@ -1,7 +1,8 @@
doctrine:
dbal: ~
-
orm:
+ mappings:
+ YamlBundle: ~
metadata_cache_driver:
type: memcache
class: Doctrine\Common\Cache\MemcacheCache
diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_single_entity_manager.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_single_entity_manager.yml
index 8be43fdeda8a..d91ff393be99 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_single_entity_manager.yml
+++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_service_single_entity_manager.yml
@@ -1,5 +1,6 @@
doctrine:
dbal:
+ default_connection: default
connections:
default:
driver: pdo_sqlite
@@ -9,14 +10,14 @@ doctrine:
memory: true
orm:
- metadata_cache_driver: apc
default_entity_manager: dm2
- default_connection: conn1
proxy_namespace: Proxies
auto_generate_proxy_classes: true
entity_managers:
default:
connection: default
+ mappings:
+ YamlBundle: ~
metadata_cache_driver:
type: memcache
class: Doctrine\Common\Cache\MemcacheCache