[DoctrineBundle] fixed some configuration options
This commit is contained in:
parent
736948887d
commit
0331501580
@ -74,8 +74,8 @@ class Configuration implements ConfigurationInterface
|
|||||||
'path',
|
'path',
|
||||||
'memory',
|
'memory',
|
||||||
'unix_socket',
|
'unix_socket',
|
||||||
'wrapper_class', 'wrapper-class', 'wrapperClass',
|
'wrapper_class',
|
||||||
'platform_service', 'platform-service', 'platform-service',
|
'platform_service',
|
||||||
'charset',
|
'charset',
|
||||||
'logging'
|
'logging'
|
||||||
) as $key) {
|
) as $key) {
|
||||||
@ -128,22 +128,13 @@ class Configuration implements ConfigurationInterface
|
|||||||
->scalarNode('platform_service')->end()
|
->scalarNode('platform_service')->end()
|
||||||
->scalarNode('charset')->end()
|
->scalarNode('charset')->end()
|
||||||
->booleanNode('logging')->defaultValue($this->debug)->end()
|
->booleanNode('logging')->defaultValue($this->debug)->end()
|
||||||
->end()
|
->scalarNode('driver_class')->end()
|
||||||
->fixXmlConfig('driver_class', 'driverClass')
|
->scalarNode('wrapper_class')->end()
|
||||||
->children()
|
->arrayNode('options')
|
||||||
->scalarNode('driverClass')->end()
|
|
||||||
->end()
|
|
||||||
->fixXmlConfig('options', 'driverOptions')
|
|
||||||
->children()
|
|
||||||
->arrayNode('driverOptions')
|
|
||||||
->useAttributeAsKey('key')
|
->useAttributeAsKey('key')
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->fixXmlConfig('wrapper_class', 'wrapperClass')
|
|
||||||
->children()
|
|
||||||
->scalarNode('wrapperClass')->end()
|
|
||||||
->end()
|
|
||||||
->end()
|
->end()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||||||
// connection
|
// connection
|
||||||
if (isset($connection['charset'])) {
|
if (isset($connection['charset'])) {
|
||||||
if ((isset($connection['driver']) && stripos($connection['driver'], 'mysql') !== false) ||
|
if ((isset($connection['driver']) && stripos($connection['driver'], 'mysql') !== false) ||
|
||||||
(isset($connection['driverClass']) && stripos($connection['driverClass'], 'mysql') !== false)) {
|
(isset($connection['driver_class']) && stripos($connection['driver_class'], 'mysql') !== false)) {
|
||||||
$mysqlSessionInit = new Definition('%doctrine.dbal.events.mysql_session_init.class%');
|
$mysqlSessionInit = new Definition('%doctrine.dbal.events.mysql_session_init.class%');
|
||||||
$mysqlSessionInit->setArguments(array($connection['charset']));
|
$mysqlSessionInit->setArguments(array($connection['charset']));
|
||||||
$mysqlSessionInit->setPublic(false);
|
$mysqlSessionInit->setPublic(false);
|
||||||
@ -119,21 +119,41 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($connection['platform_service'])) {
|
$options = $this->getConnectionOptions($connection);
|
||||||
$connection['platform'] = new Reference($connection['platform_service']);
|
|
||||||
unset($connection['platform_service']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new DefinitionDecorator('doctrine.dbal.connection'))
|
->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new DefinitionDecorator('doctrine.dbal.connection'))
|
||||||
->setArguments(array(
|
->setArguments(array(
|
||||||
$connection,
|
$options,
|
||||||
new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)),
|
new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)),
|
||||||
new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name)),
|
new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name)),
|
||||||
))
|
))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getConnectionOptions($connection)
|
||||||
|
{
|
||||||
|
$options = $connection;
|
||||||
|
|
||||||
|
if (isset($options['platform_service'])) {
|
||||||
|
$options['platform'] = new Reference($options['platform_service']);
|
||||||
|
unset($options['platform_service']);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array(
|
||||||
|
'options' => 'driverOptions',
|
||||||
|
'driver_class' => 'driverClass',
|
||||||
|
'wrapper_class' => 'wrapperClass',
|
||||||
|
) as $old => $new) {
|
||||||
|
if (isset($options[$old])) {
|
||||||
|
$options[$new] = $options[$old];
|
||||||
|
unset($options[$old]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the Doctrine ORM configuration.
|
* Loads the Doctrine ORM configuration.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user