Merge pull request #309 from K-Phoen/infer-default-connection

Fix default connection detection when not explicitly set in the config
This commit is contained in:
Toni Uebernickel 2015-06-10 20:56:30 +02:00
commit 1701a4e67d
2 changed files with 3 additions and 2 deletions

View file

@ -354,7 +354,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']);
}
/**

View file

@ -55,9 +55,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'])) {