Skip to content

Commit

Permalink
Merge pull request #306 from K-Phoen/adapter_configuration
Browse files Browse the repository at this point in the history
Allow pdo_* values as valid adapters
  • Loading branch information
Marc J. Schmidt committed Nov 19, 2014
2 parents 3278c79 + 527a998 commit 87b5597
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions DependencyInjection/Configuration.php
Expand Up @@ -27,6 +27,8 @@ public function __construct($debug = true)

protected function addDatabaseSection(ArrayNodeDefinition $node)
{
$validAdapters = array('mysql', 'pgsql', 'sqlite', 'mssql', 'sqlsrv', 'oracle');

$node
->children()
->arrayNode('database')
Expand Down Expand Up @@ -54,12 +56,26 @@ protected function addDatabaseSection(ArrayNodeDefinition $node)
->fixXmlConfig('slave')
->children()
->scalarNode('classname')->defaultValue($this->debug ? '\Propel\Runtime\Connection\DebugPDO' : '\Propel\Runtime\Connection\ConnectionWrapper')->end()
->enumNode('adapter')
->scalarNode('adapter')
->isRequired()
->cannotBeEmpty()
->values(array('mysql', 'pgsql', 'sqlite', 'mssql', 'sqlsrv', 'oracle'))
->beforeNormalization()
->ifString()
->then(function ($v) { return str_replace('pdo_', '', strtolower($v)); })
->end()
->validate()
->ifNotInArray($validAdapters)
->thenInvalid('The adapter %s is not supported. Please choose one of ' . implode(', ', $validAdapters))
->end()
->end()
->scalarNode('dsn')
->isRequired()
->cannotBeEmpty()
->beforeNormalization()
->ifString()
->then(function ($v) { return str_replace('pdo_', '', $v); })
->end()
->end()
->scalarNode('dsn')->isRequired()->cannotBeEmpty()->end()
->scalarNode('user')->isRequired()->end()
->scalarNode('password')->isRequired()->treatNullLike('')->end()
->arrayNode('options')
Expand Down

0 comments on commit 87b5597

Please sign in to comment.