. */ namespace Doctrine\DBAL; use Doctrine\DBAL\Types\Type; /** * Configuration container for the Doctrine DBAL. * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.0 * @version $Revision: 3938 $ * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel * * @internal When adding a new configuration option just write a getter/setter * pair and add the option to the _attributes array with a proper default value. */ class Configuration { /** * The attributes that are contained in the configuration. * Values are default values. * * @var array */ protected $_attributes = array(); /** * Creates a new DBAL configuration instance. */ public function __construct() { $this->_attributes = array( 'sqlLogger' => null ); } /** * Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled. * * @param SqlLogger $logger */ public function setSqlLogger($logger) { $this->_attributes['sqlLogger'] = $logger; } /** * Gets the SQL logger that is used. * * @return SqlLogger */ public function getSqlLogger() { return $this->_attributes['sqlLogger']; } /** * Defines new custom types to be supported by Doctrine * * @param array $types Key-value map of types to include * @param boolean $override Optional flag to support only inclusion or also override * @throws DoctrineException */ public function setCustomTypes(array $types, $override = false) { foreach ($types as $name => $typeClassName) { $method = (Type::hasType($name) ? 'override' : 'add') . 'Type'; Type::$method($name, $typeClassName); } } /** * Overrides existent types in Doctrine * * @param array $types Key-value map of types to override * @throws DoctrineException */ public function setTypeOverrides(array $overrides) { foreach ($override as $name => $typeClassName) { Type::overrideType($name, $typeClassName); } } }