Set a default value for the classname
This commit is contained in:
parent
09e4da0c19
commit
c3e5272293
|
@ -11,10 +11,101 @@
|
|||
namespace Propel\PropelBundle\DependencyInjection;
|
||||
|
||||
use Propel\Common\Config\PropelConfiguration;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
|
||||
/**
|
||||
* This class contains the configuration information for the bundle
|
||||
*/
|
||||
class Configuration extends PropelConfiguration
|
||||
{
|
||||
private $debug;
|
||||
|
||||
public function __construct($debug = true)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
protected function addDatabaseSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('database')
|
||||
->isRequired()
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('connections')
|
||||
->isRequired()
|
||||
->requiresAtLeastOneElement()
|
||||
->normalizeKeys(false)
|
||||
->prototype('array')
|
||||
->fixXmlConfig('slave')
|
||||
->children()
|
||||
->scalarNode('classname')->defaultValue($this->debug ? '\Propel\Runtime\Connection\DebugPDO' : '\Propel\Runtime\Connection\ConnectionWrapper')->end()
|
||||
->enumNode('adapter')
|
||||
->isRequired()
|
||||
->cannotBeEmpty()
|
||||
->values(array('mysql', 'pgsql', 'sqlite', 'mssql', 'sqlsrv', 'oracle'))
|
||||
->end()
|
||||
->scalarNode('dsn')->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('user')->isRequired()->end()
|
||||
->scalarNode('password')->isRequired()->treatNullLike('')->end()
|
||||
->arrayNode('options')
|
||||
->children()
|
||||
->booleanNode('ATTR_PERSISTENT')->defaultFalse()->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('attributes')
|
||||
->children()
|
||||
->booleanNode('ATTR_EMULATE_PREPARES')->defaultFalse()->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('settings')
|
||||
->fixXmlConfig('query', 'queries')
|
||||
->children()
|
||||
->scalarNode('charset')->defaultValue('utf8')->end()
|
||||
->arrayNode('queries')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('slaves')
|
||||
->prototype('array')
|
||||
->children()
|
||||
->scalarNode('dsn')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('adapters')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('mysql')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('tableType')->defaultValue('InnoDB')->treatNullLike('InnoDB')->end()
|
||||
->scalarNode('tableEngineKeyword')->defaultValue('ENGINE')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('sqlite')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('foreignKey')->end()
|
||||
->scalarNode('tableAlteringWorkaround')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('oracle')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('autoincrementSequencePattern')->defaultValue('${table}_SEQ')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end() //adapters
|
||||
->end()
|
||||
->end() //database
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,7 @@ class PropelExtension extends Extension
|
|||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $processor->processConfiguration($configuration, $configs);
|
||||
|
||||
// @todo: restore
|
||||
$container->setParameter('propel.logging', true); //$config['logging']);
|
||||
$container->setParameter('propel.logging', $container->getParameter('kernel.debug'));
|
||||
$container->setParameter('propel.configuration', $config);
|
||||
|
||||
// Load services
|
||||
|
@ -49,6 +48,11 @@ class PropelExtension extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($container->getParameter('kernel.debug'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base path for the XSD files.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue