diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 710ba8e9..328d47eb 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -209,6 +209,7 @@ private function addOdmSection(ArrayNodeDefinition $node)
'locales' => true,
'locale' => true,
'locale_chooser' => true,
+ 'default_locale' => true,
);
$documentManagers = array();
foreach ($v as $key => $value) {
@@ -237,6 +238,7 @@ private function addOdmSection(ArrayNodeDefinition $node)
->values(array('hardcoded', 'merge', 'replace'))
->defaultValue('hardcoded')
->end()
+ ->scalarNode('default_locale')->end()
->arrayNode('namespaces')
->addDefaultsIfNotSet()
->children()
diff --git a/DependencyInjection/DoctrinePHPCRExtension.php b/DependencyInjection/DoctrinePHPCRExtension.php
index 3b645497..90a59485 100644
--- a/DependencyInjection/DoctrinePHPCRExtension.php
+++ b/DependencyInjection/DoctrinePHPCRExtension.php
@@ -387,6 +387,15 @@ private function loadOdmLocales(array $config, ContainerBuilder $container)
$container->setParameter('doctrine_phpcr.odm.locales', $config['locales']);
$container->setParameter('doctrine_phpcr.odm.allowed_locales', array_keys($config['locales']));
+ if (isset($config['default_locale']) && !is_null($config['default_locale'])) {
+ $defaultLocale = $config['default_locale'];
+ if (!isset($config['locales'][$defaultLocale])) {
+ throw new InvalidConfigurationException('Default locale must be listed in locale list');
+ }
+ } else {
+ $defaultLocale = key($config['locales']);
+ }
+ $container->setParameter('doctrine_phpcr.odm.default_locale', $defaultLocale);
$container->setParameter('doctrine_phpcr.odm.default_locale', key($config['locales']));
$container->setParameter('doctrine_phpcr.odm.locale_fallback', $config['locale_fallback'] == 'hardcoded' ? null : $config['locale_fallback']);
diff --git a/Tests/Resources/Fixtures/config/single.php b/Tests/Resources/Fixtures/config/single.php
index d5a2f14b..a2aaa0e1 100644
--- a/Tests/Resources/Fixtures/config/single.php
+++ b/Tests/Resources/Fixtures/config/single.php
@@ -57,6 +57,7 @@
'fr' => array('en', 'de'),
),
'locale_fallback' => 'hardcoded',
+ 'default_locale' => 'fr',
),
'jackrabbit_jar' => '/path/to/jackrabbit.jar',
'dump_max_line_length' => 20,
diff --git a/Tests/Resources/Fixtures/config/single.xml b/Tests/Resources/Fixtures/config/single.xml
index 04f1c64f..1ee8a25d 100644
--- a/Tests/Resources/Fixtures/config/single.xml
+++ b/Tests/Resources/Fixtures/config/single.xml
@@ -68,6 +68,7 @@
en
de
+ fr
diff --git a/Tests/Resources/Fixtures/config/single.yml b/Tests/Resources/Fixtures/config/single.yml
index 068211e3..daffae48 100644
--- a/Tests/Resources/Fixtures/config/single.yml
+++ b/Tests/Resources/Fixtures/config/single.yml
@@ -46,6 +46,7 @@ doctrine_phpcr:
de: [en, fr]
fr: [en, de]
locale_fallback: hardcoded
+ default_locale: fr
jackrabbit_jar: /path/to/jackrabbit.jar
dump_max_line_length: 20
diff --git a/Tests/Unit/DependencyInjection/ConfigurationTest.php b/Tests/Unit/DependencyInjection/ConfigurationTest.php
index 32eb0a06..f2c3490f 100644
--- a/Tests/Unit/DependencyInjection/ConfigurationTest.php
+++ b/Tests/Unit/DependencyInjection/ConfigurationTest.php
@@ -85,6 +85,7 @@ public function configurations()
'fr' => array('en', 'de'),
),
'locale_fallback' => 'hardcoded',
+ 'default_locale' => 'fr',
'default_document_manager' => 'default',
'document_managers' => array(
'default' => array(