[DoctrineBundle] added back the possibility to define a single entity manager with a shorter syntax (same reasonning as the previous commit for DBAL)
This commit is contained in:
parent
3f1d969fcd
commit
059104a9e7
@ -139,6 +139,22 @@ class Configuration implements ConfigurationInterface
|
|||||||
$node
|
$node
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('orm')
|
->arrayNode('orm')
|
||||||
|
->beforeNormalization()
|
||||||
|
->ifTrue(function ($v) { return is_array($v) && !array_key_exists('entity_managers', $v) && !array_key_exists('entity_manager', $v); })
|
||||||
|
->then(function ($v) {
|
||||||
|
$entityManager = array();
|
||||||
|
foreach (array('result_cache_driver', 'result-cache-driver', 'metadata_cache_driver', 'metadata-cache-driver', 'query_cache_driver', 'query-cache-driver', 'mappings', 'mapping', 'connection') as $key) {
|
||||||
|
if (array_key_exists($key, $v)) {
|
||||||
|
$entityManager[$key] = $v[$key];
|
||||||
|
unset($v[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$v['default_entity_manager'] = isset($v['default_entity_manager']) ? (string) $v['default_entity_manager'] : 'default';
|
||||||
|
$v['entity_managers'] = array($v['default_entity_manager'] => $entityManager);
|
||||||
|
|
||||||
|
return $v;
|
||||||
|
})
|
||||||
|
->end()
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('default_entity_manager')->end()
|
->scalarNode('default_entity_manager')->end()
|
||||||
->booleanNode('auto_generate_proxy_classes')->defaultFalse()->end()
|
->booleanNode('auto_generate_proxy_classes')->defaultFalse()->end()
|
||||||
|
@ -11,15 +11,13 @@
|
|||||||
<connection name="default" dbname="db" />
|
<connection name="default" dbname="db" />
|
||||||
</dbal>
|
</dbal>
|
||||||
|
|
||||||
<orm default-entity-manager="default">
|
<orm>
|
||||||
<entity-manager name="default">
|
|
||||||
<mapping name="AnnotationsBundle" />
|
<mapping name="AnnotationsBundle" />
|
||||||
<mapping name="YamlBundle" dir="Resources/config/doctrine/metadata" alias="yml" />
|
<mapping name="YamlBundle" dir="Resources/config/doctrine/metadata" alias="yml" />
|
||||||
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
|
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
|
||||||
dir="%kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata"
|
dir="%kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata"
|
||||||
alias="TestAlias"
|
alias="TestAlias"
|
||||||
/>
|
/>
|
||||||
</entity-manager>
|
|
||||||
</orm>
|
</orm>
|
||||||
</config>
|
</config>
|
||||||
</srv:container>
|
</srv:container>
|
||||||
|
@ -6,9 +6,6 @@ doctrine:
|
|||||||
dbname: db
|
dbname: db
|
||||||
|
|
||||||
orm:
|
orm:
|
||||||
default_entity_manager: default
|
|
||||||
entity_managers:
|
|
||||||
default:
|
|
||||||
mappings:
|
mappings:
|
||||||
AnnotationsBundle: ~
|
AnnotationsBundle: ~
|
||||||
YamlBundle:
|
YamlBundle:
|
||||||
|
Reference in New Issue
Block a user