[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
|
||||
->children()
|
||||
->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()
|
||||
->scalarNode('default_entity_manager')->end()
|
||||
->booleanNode('auto_generate_proxy_classes')->defaultFalse()->end()
|
||||
|
@ -11,15 +11,13 @@
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<mapping name="AnnotationsBundle" />
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine/metadata" alias="yml" />
|
||||
<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"
|
||||
alias="TestAlias"
|
||||
/>
|
||||
</entity-manager>
|
||||
<orm>
|
||||
<mapping name="AnnotationsBundle" />
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine/metadata" alias="yml" />
|
||||
<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"
|
||||
alias="TestAlias"
|
||||
/>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
||||
|
@ -6,16 +6,13 @@ doctrine:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
default_entity_manager: default
|
||||
entity_managers:
|
||||
default:
|
||||
mappings:
|
||||
AnnotationsBundle: ~
|
||||
YamlBundle:
|
||||
dir: Resources/config/doctrine/metadata
|
||||
alias: yml
|
||||
manual:
|
||||
type: xml
|
||||
prefix: Fixtures\Bundles\XmlBundle
|
||||
dir: %kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata
|
||||
alias: TestAlias
|
||||
mappings:
|
||||
AnnotationsBundle: ~
|
||||
YamlBundle:
|
||||
dir: Resources/config/doctrine/metadata
|
||||
alias: yml
|
||||
manual:
|
||||
type: xml
|
||||
prefix: Fixtures\Bundles\XmlBundle
|
||||
dir: %kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata
|
||||
alias: TestAlias
|
||||
|
Reference in New Issue
Block a user