From 67eeb882e79a203a9d2e977cc1c73ed1595c38de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Fri, 21 Nov 2014 13:01:36 +0000 Subject: [PATCH] Fix default connection detection when not explicitly set in the configuration --- Command/AbstractCommand.php | 2 +- PropelBundle.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Command/AbstractCommand.php b/Command/AbstractCommand.php index 0b90282..f337951 100644 --- a/Command/AbstractCommand.php +++ b/Command/AbstractCommand.php @@ -346,7 +346,7 @@ abstract class AbstractCommand extends ContainerAwareCommand { $config = $this->getContainer()->getParameter('propel.configuration'); - return $config['generator']['defaultConnection']; + return !empty($config['generator']['defaultConnection']) ? $config['generator']['defaultConnection'] : key($config['database']['connections']); } /** diff --git a/PropelBundle.php b/PropelBundle.php index a6d46f5..8094b08 100644 --- a/PropelBundle.php +++ b/PropelBundle.php @@ -48,9 +48,10 @@ class PropelBundle extends Bundle protected function configureConnections() { $config = $this->container->getParameter('propel.configuration'); + $defaultConnection = !empty($config['runtime']['defaultConnection']) ? $config['runtime']['defaultConnection'] : key($config['database']['connections']); $serviceContainer = Propel::getServiceContainer(); - $serviceContainer->setDefaultDatasource($config['runtime']['defaultConnection']); + $serviceContainer->setDefaultDatasource($defaultConnection); foreach ($config['database']['connections'] as $name => $config) { if (!empty($config['slaves'])) {