Commit 6be6f40e authored by romanb's avatar romanb

Splitting DBAL/ORM configuration.

parent 99710570
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
#namespace Doctrine::Common; #namespace Doctrine\DBAL;
#use Doctrine::Common::NullObject;
/** /**
* The Configuration is the container for all configuration options of Doctrine. * The Configuration is the container for all configuration options of Doctrine.
...@@ -33,7 +31,7 @@ ...@@ -33,7 +31,7 @@
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
class Doctrine_Common_Configuration class Doctrine_DBAL_Configuration
{ {
/** /**
* The attributes that are contained in the configuration. * The attributes that are contained in the configuration.
...@@ -41,21 +39,20 @@ class Doctrine_Common_Configuration ...@@ -41,21 +39,20 @@ class Doctrine_Common_Configuration
* *
* @var array * @var array
*/ */
private $_attributes = array( protected $_attributes = array();
'quoteIdentifiers' => false,
'indexNameFormat' => '%s_idx',
'sequenceNameFormat' => '%s_seq',
'tableNameFormat' => '%s',
'resultCacheImpl' => null,
'queryCacheImpl' => null,
'metadataCacheImpl' => null,
);
/** /**
* Creates a new configuration that can be used for Doctrine. * Creates a new configuration that can be used for Doctrine.
*/ */
public function __construct() public function __construct()
{} {
$this->_attributes = array(
'quoteIdentifiers' => false,
'indexNameFormat' => '%s_idx',
'sequenceNameFormat' => '%s_seq',
'tableNameFormat' => '%s'
);
}
public function getQuoteIdentifiers() public function getQuoteIdentifiers()
{ {
...@@ -100,40 +97,10 @@ class Doctrine_Common_Configuration ...@@ -100,40 +97,10 @@ class Doctrine_Common_Configuration
$this->_attributes['tableNameFormat'] = $format; $this->_attributes['tableNameFormat'] = $format;
} }
public function getResultCacheImpl()
{
return $this->_attributes['resultCacheImpl'];
}
public function setResultCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['resultCacheImpl'] = $cacheImpl;
}
public function getQueryCacheImpl()
{
return $this->_attributes['queryCacheImpl'];
}
public function setQueryCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['queryCacheImpl'] = $cacheImpl;
}
public function getMetadataCacheImpl()
{
return $this->_attributes['metadataCacheImpl'];
}
public function setMetadataCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['metadataCacheImpl'] = $cacheImpl;
}
public function setCustomTypes(array $types) public function setCustomTypes(array $types)
{ {
foreach ($types as $name => $typeClassName) { foreach ($types as $name => $typeClassName) {
Doctrine_DataType::addCustomType($name, $typeClassName); Doctrine_DBAL_Types_Type::addCustomType($name, $typeClassName);
} }
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#namespace Doctrine\DBAL; #namespace Doctrine\DBAL;
#use Doctrine\Common\Configuration;
#use Doctrine\Common\EventManager; #use Doctrine\Common\EventManager;
#use Doctrine\DBAL\Exceptions\ConnectionException; #use Doctrine\DBAL\Exceptions\ConnectionException;
...@@ -83,7 +82,7 @@ class Doctrine_DBAL_Connection ...@@ -83,7 +82,7 @@ class Doctrine_DBAL_Connection
/** /**
* The Configuration. * The Configuration.
* *
* @var Doctrine\Common\Configuration * @var Doctrine\DBAL\Configuration
*/ */
protected $_config; protected $_config;
...@@ -157,7 +156,7 @@ class Doctrine_DBAL_Connection ...@@ -157,7 +156,7 @@ class Doctrine_DBAL_Connection
* @param array $params The connection parameters. * @param array $params The connection parameters.
*/ */
public function __construct(array $params, Doctrine_DBAL_Driver $driver, public function __construct(array $params, Doctrine_DBAL_Driver $driver,
Doctrine_Common_Configuration $config = null, Doctrine_DBAL_Configuration $config = null,
Doctrine_Common_EventManager $eventManager = null) Doctrine_Common_EventManager $eventManager = null)
{ {
$this->_driver = $driver; $this->_driver = $driver;
...@@ -170,7 +169,7 @@ class Doctrine_DBAL_Connection ...@@ -170,7 +169,7 @@ class Doctrine_DBAL_Connection
// Create default config and event manager if none given // Create default config and event manager if none given
if ( ! $config) { if ( ! $config) {
$this->_config = new Doctrine_Common_Configuration(); $this->_config = new Doctrine_DBAL_Configuration();
} }
if ( ! $eventManager) { if ( ! $eventManager) {
$this->_eventManager = new Doctrine_Common_EventManager(); $this->_eventManager = new Doctrine_Common_EventManager();
......
...@@ -91,12 +91,12 @@ final class Doctrine_DBAL_DriverManager ...@@ -91,12 +91,12 @@ final class Doctrine_DBAL_DriverManager
* @return Doctrine::DBAL::Connection * @return Doctrine::DBAL::Connection
*/ */
public static function getConnection(array $params, public static function getConnection(array $params,
Doctrine_Common_Configuration $config = null, Doctrine_DBAL_Configuration $config = null,
Doctrine_Common_EventManager $eventManager = null) Doctrine_Common_EventManager $eventManager = null)
{ {
// create default config and event manager, if not set // create default config and event manager, if not set
if ( ! $config) { if ( ! $config) {
$config = new Doctrine_Common_Configuration(); $config = new Doctrine_DBAL_Configuration();
} }
if ( ! $eventManager) { if ( ! $eventManager) {
$eventManager = new Doctrine_Common_EventManager(); $eventManager = new Doctrine_Common_EventManager();
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine\ORM;
#use Doctrine\DBAL\Configuration;
/**
* The Configuration is the container for all configuration options of Doctrine.
* It combines all configuration options from DBAL & ORM.
*
* 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.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class Doctrine_ORM_Configuration extends Doctrine_DBAL_Configuration
{
/**
* Creates a new configuration that can be used for Doctrine.
*/
public function __construct()
{
$this->_attributes = array_merge($this->_attributes, array(
'resultCacheImpl' => null,
'queryCacheImpl' => null,
'metadataCacheImpl' => null
));
}
public function getResultCacheImpl()
{
return $this->_attributes['resultCacheImpl'];
}
public function setResultCacheImpl($cacheImpl)
{
$this->_attributes['resultCacheImpl'] = $cacheImpl;
}
public function getQueryCacheImpl()
{
return $this->_attributes['queryCacheImpl'];
}
public function setQueryCacheImpl($cacheImpl)
{
$this->_attributes['queryCacheImpl'] = $cacheImpl;
}
public function getMetadataCacheImpl()
{
return $this->_attributes['metadataCacheImpl'];
}
public function setMetadataCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['metadataCacheImpl'] = $cacheImpl;
}
}
\ No newline at end of file
...@@ -151,7 +151,7 @@ class Doctrine_ORM_EntityManager ...@@ -151,7 +151,7 @@ class Doctrine_ORM_EntityManager
* @param Doctrine_Connection $conn * @param Doctrine_Connection $conn
* @param string $name * @param string $name
*/ */
protected function __construct(Doctrine_DBAL_Connection $conn, $name, Doctrine_Common_Configuration $config, protected function __construct(Doctrine_DBAL_Connection $conn, $name, Doctrine_ORM_Configuration $config,
Doctrine_Common_EventManager $eventManager) Doctrine_Common_EventManager $eventManager)
{ {
$this->_conn = $conn; $this->_conn = $conn;
...@@ -722,7 +722,7 @@ class Doctrine_ORM_EntityManager ...@@ -722,7 +722,7 @@ class Doctrine_ORM_EntityManager
* @param EventManager $eventManager The EventManager instance to use. * @param EventManager $eventManager The EventManager instance to use.
* @return EntityManager The created EntityManager. * @return EntityManager The created EntityManager.
*/ */
public static function create($conn, $name, Doctrine_Common_Configuration $config = null, public static function create($conn, $name, Doctrine_ORM_Configuration $config = null,
Doctrine_Common_EventManager $eventManager = null) Doctrine_Common_EventManager $eventManager = null)
{ {
if (is_array($conn)) { if (is_array($conn)) {
...@@ -732,7 +732,7 @@ class Doctrine_ORM_EntityManager ...@@ -732,7 +732,7 @@ class Doctrine_ORM_EntityManager
} }
if (is_null($config)) { if (is_null($config)) {
$config = new Doctrine_Common_Configuration(); $config = new Doctrine_ORM_Configuration();
} }
if (is_null($eventManager)) { if (is_null($eventManager)) {
$eventManager = new Doctrine_Common_EventManager(); $eventManager = new Doctrine_Common_EventManager();
......
...@@ -15,7 +15,7 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase ...@@ -15,7 +15,7 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
if (isset($this->sharedFixture['em'])) { if (isset($this->sharedFixture['em'])) {
$this->_em = $this->sharedFixture['em']; $this->_em = $this->sharedFixture['em'];
} else { } else {
$config = new Doctrine_Common_Configuration(); $config = new Doctrine_ORM_Configuration();
$eventManager = new Doctrine_Common_EventManager(); $eventManager = new Doctrine_Common_EventManager();
$connectionOptions = array( $connectionOptions = array(
'driverClass' => 'Doctrine_DriverMock', 'driverClass' => 'Doctrine_DriverMock',
......
...@@ -10,7 +10,7 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite ...@@ -10,7 +10,7 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
{ {
protected function setUp() protected function setUp()
{ {
$config = new Doctrine_Common_Configuration(); $config = new Doctrine_ORM_Configuration();
$eventManager = new Doctrine_Common_EventManager(); $eventManager = new Doctrine_Common_EventManager();
$connectionOptions = array( $connectionOptions = array(
'driverClass' => 'Doctrine_DriverMock', 'driverClass' => 'Doctrine_DriverMock',
......
...@@ -46,11 +46,11 @@ class Doctrine_EntityManagerMock extends Doctrine_ORM_EntityManager ...@@ -46,11 +46,11 @@ class Doctrine_EntityManagerMock extends Doctrine_ORM_EntityManager
* @param Doctrine_EventManager $eventManager * @param Doctrine_EventManager $eventManager
* @return unknown * @return unknown
*/ */
public static function create($conn, $name, Doctrine_Common_Configuration $config = null, public static function create($conn, $name, Doctrine_ORM_Configuration $config = null,
Doctrine_Common_EventManager $eventManager = null) Doctrine_Common_EventManager $eventManager = null)
{ {
if (is_null($config)) { if (is_null($config)) {
$config = new Doctrine_Common_Configuration(); $config = new Doctrine_ORM_Configuration();
} }
if (is_null($eventManager)) { if (is_null($eventManager)) {
$eventManager = new Doctrine_Common_EventManager(); $eventManager = new Doctrine_Common_EventManager();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment