Merge branch 'klaasn-master'

This commit is contained in:
William DURAND 2011-02-23 16:34:16 +01:00
commit 195b596ee2
3 changed files with 47 additions and 33 deletions

View file

@ -7,6 +7,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Config\FileLocator;
class PropelExtension extends Extension
{
@ -16,12 +17,19 @@ class PropelExtension extends Extension
* @param array $configs An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function configLoad(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container)
{
$dbal = array();
foreach ($configs as $config) {
if (isset($config['dbal'])) {
$dbal[] = $config['dbal'];
}
}
$config = $configs[0];
if (!$container->hasDefinition('propel')) {
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('propel.xml');
}
@ -47,6 +55,10 @@ class PropelExtension extends Extension
$charset = 'UTF8';
}
$container->setParameter('propel.charset', $charset);
if (!empty($dbal)) {
$this->dbalLoad($dbal, $container);
}
}
/**
@ -55,7 +67,7 @@ class PropelExtension extends Extension
* @param array $configs An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function dbalLoad(array $configs, ContainerBuilder $container)
protected function dbalLoad(array $configs, ContainerBuilder $container)
{
if (!$container->hasDefinition('propel')) {
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');

31
README
View file

@ -66,26 +66,27 @@ Sample Configuration
### Project configuration
# in app/config/config.yml
propel.config:
propel:
path: "%kernel.root_dir%/../vendor/propel"
phing_path: "%kernel.root_dir%/../vendor/phing"
# charset: "UTF8"
# in app/config/config*.yml
propel.dbal:
driver: mysql
user: root
password: null
dsn: mysql:host=localhost;dbname=test
options: {}
# default_connection: default
# connections:
# default:
# driver: mysql
# user: root
# password: null
# dsn: mysql:host=localhost;dbname=test
# options: {}
propel:
dbal:
driver: mysql
user: root
password: null
dsn: mysql:host=localhost;dbname=test
options: {}
# default_connection: default
# connections:
# default:
# driver: mysql
# user: root
# password: null
# dsn: mysql:host=localhost;dbname=test
# options: {}
### Sample Schema

View file

@ -66,26 +66,27 @@ Sample Configuration
### Project configuration
# in app/config/config.yml
propel.config:
propel:
path: "%kernel.root_dir%/../vendor/propel"
phing_path: "%kernel.root_dir%/../vendor/phing"
# charset: "UTF8"
# in app/config/config*.yml
propel.dbal:
driver: mysql
user: root
password: null
dsn: mysql:host=localhost;dbname=test
options: {}
# default_connection: default
# connections:
# default:
# driver: mysql
# user: root
# password: null
# dsn: mysql:host=localhost;dbname=test
# options: {}
propel:
dbal:
driver: mysql
user: root
password: null
dsn: mysql:host=localhost;dbname=test
options: {}
# default_connection: default
# connections:
# default:
# driver: mysql
# user: root
# password: null
# dsn: mysql:host=localhost;dbname=test
# options: {}
### Sample Schema