diff --git a/DependencyInjection/PropelExtension.php b/DependencyInjection/PropelExtension.php index 84b0a51..fa9b83a 100644 --- a/DependencyInjection/PropelExtension.php +++ b/DependencyInjection/PropelExtension.php @@ -52,6 +52,7 @@ class PropelExtension extends Extension } // build properties + // @todo: store them as container parameters and use them in commands if (isset($config['build_properties']) && is_array($config['build_properties'])) { $buildProperties = $config['build_properties']; } else { diff --git a/PropelBundle.php b/PropelBundle.php index 2e8ecc9..800e1b5 100644 --- a/PropelBundle.php +++ b/PropelBundle.php @@ -12,6 +12,7 @@ namespace Propel\PropelBundle; use Propel\Runtime\Propel; use Propel\Runtime\Connection\ConnectionManagerSingle; +use Propel\Runtime\Connection\ConnectionManagerMasterSlave; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -47,8 +48,17 @@ class PropelBundle extends Bundle $serviceContainer->setDefaultDatasource($default_datasource); foreach ($connections_config as $name => $config) { - $manager = new ConnectionManagerSingle(); - $manager->setConfiguration($config['connection']); + if (isset($config['slaves'])) { + $manager = new ConnectionManagerMasterSlave(); + + // configure the master (write) connection + $manager->setWriteConfiguration($config['connection']); + // configure the slave (read) connections + $manager->setReadConfiguration($config['slaves']); + } else { + $manager = new ConnectionManagerSingle(); + $manager->setConfiguration($config['connection']); + } $serviceContainer->setAdapterClass($name, $config['adapter']); $serviceContainer->setConnectionManager($name, $manager);