Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
6be6f40e
Commit
6be6f40e
authored
Dec 18, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Splitting DBAL/ORM configuration.
parent
99710570
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
58 deletions
+103
-58
Configuration.php
lib/Doctrine/DBAL/Configuration.php
+12
-45
Connection.php
lib/Doctrine/DBAL/Connection.php
+3
-4
DriverManager.php
lib/Doctrine/DBAL/DriverManager.php
+2
-2
Configuration.php
lib/Doctrine/ORM/Configuration.php
+79
-0
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+3
-3
Doctrine_OrmTestCase.php
tests/lib/Doctrine_OrmTestCase.php
+1
-1
Doctrine_OrmTestSuite.php
tests/lib/Doctrine_OrmTestSuite.php
+1
-1
Doctrine_EntityManagerMock.php
tests/lib/mocks/Doctrine_EntityManagerMock.php
+2
-2
No files found.
lib/Doctrine/
Common
/Configuration.php
→
lib/Doctrine/
DBAL
/Configuration.php
View file @
6be6f40e
...
...
@@ -19,9 +19,7 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::Common;
#use Doctrine::Common::NullObject;
#namespace Doctrine\DBAL;
/**
* The Configuration is the container for all configuration options of Doctrine.
...
...
@@ -33,7 +31,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class
Doctrine_
Common
_Configuration
class
Doctrine_
DBAL
_Configuration
{
/**
* The attributes that are contained in the configuration.
...
...
@@ -41,21 +39,20 @@ class Doctrine_Common_Configuration
*
* @var array
*/
private
$_attributes
=
array
(
'quoteIdentifiers'
=>
false
,
'indexNameFormat'
=>
'%s_idx'
,
'sequenceNameFormat'
=>
'%s_seq'
,
'tableNameFormat'
=>
'%s'
,
'resultCacheImpl'
=>
null
,
'queryCacheImpl'
=>
null
,
'metadataCacheImpl'
=>
null
,
);
protected
$_attributes
=
array
();
/**
* Creates a new configuration that can be used for Doctrine.
*/
public
function
__construct
()
{}
{
$this
->
_attributes
=
array
(
'quoteIdentifiers'
=>
false
,
'indexNameFormat'
=>
'%s_idx'
,
'sequenceNameFormat'
=>
'%s_seq'
,
'tableNameFormat'
=>
'%s'
);
}
public
function
getQuoteIdentifiers
()
{
...
...
@@ -100,40 +97,10 @@ class Doctrine_Common_Configuration
$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
)
{
foreach
(
$types
as
$name
=>
$typeClassName
)
{
Doctrine_D
ata
Type
::
addCustomType
(
$name
,
$typeClassName
);
Doctrine_D
BAL_Types_
Type
::
addCustomType
(
$name
,
$typeClassName
);
}
}
...
...
lib/Doctrine/DBAL/Connection.php
View file @
6be6f40e
...
...
@@ -21,7 +21,6 @@
#namespace Doctrine\DBAL;
#use Doctrine\Common\Configuration;
#use Doctrine\Common\EventManager;
#use Doctrine\DBAL\Exceptions\ConnectionException;
...
...
@@ -83,7 +82,7 @@ class Doctrine_DBAL_Connection
/**
* The Configuration.
*
* @var Doctrine\
Common
\Configuration
* @var Doctrine\
DBAL
\Configuration
*/
protected
$_config
;
...
...
@@ -157,7 +156,7 @@ class Doctrine_DBAL_Connection
* @param array $params The connection parameters.
*/
public
function
__construct
(
array
$params
,
Doctrine_DBAL_Driver
$driver
,
Doctrine_
Common
_Configuration
$config
=
null
,
Doctrine_
DBAL
_Configuration
$config
=
null
,
Doctrine_Common_EventManager
$eventManager
=
null
)
{
$this
->
_driver
=
$driver
;
...
...
@@ -170,7 +169,7 @@ class Doctrine_DBAL_Connection
// Create default config and event manager if none given
if
(
!
$config
)
{
$this
->
_config
=
new
Doctrine_
Common
_Configuration
();
$this
->
_config
=
new
Doctrine_
DBAL
_Configuration
();
}
if
(
!
$eventManager
)
{
$this
->
_eventManager
=
new
Doctrine_Common_EventManager
();
...
...
lib/Doctrine/DBAL/DriverManager.php
View file @
6be6f40e
...
...
@@ -91,12 +91,12 @@ final class Doctrine_DBAL_DriverManager
* @return Doctrine::DBAL::Connection
*/
public
static
function
getConnection
(
array
$params
,
Doctrine_
Common
_Configuration
$config
=
null
,
Doctrine_
DBAL
_Configuration
$config
=
null
,
Doctrine_Common_EventManager
$eventManager
=
null
)
{
// create default config and event manager, if not set
if
(
!
$config
)
{
$config
=
new
Doctrine_
Common
_Configuration
();
$config
=
new
Doctrine_
DBAL
_Configuration
();
}
if
(
!
$eventManager
)
{
$eventManager
=
new
Doctrine_Common_EventManager
();
...
...
lib/Doctrine/ORM/Configuration.php
0 → 100644
View file @
6be6f40e
<?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
lib/Doctrine/ORM/EntityManager.php
View file @
6be6f40e
...
...
@@ -151,7 +151,7 @@ class Doctrine_ORM_EntityManager
* @param Doctrine_Connection $conn
* @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
)
{
$this
->
_conn
=
$conn
;
...
...
@@ -722,7 +722,7 @@ class Doctrine_ORM_EntityManager
* @param EventManager $eventManager The EventManager instance to use.
* @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
)
{
if
(
is_array
(
$conn
))
{
...
...
@@ -732,7 +732,7 @@ class Doctrine_ORM_EntityManager
}
if
(
is_null
(
$config
))
{
$config
=
new
Doctrine_
Common
_Configuration
();
$config
=
new
Doctrine_
ORM
_Configuration
();
}
if
(
is_null
(
$eventManager
))
{
$eventManager
=
new
Doctrine_Common_EventManager
();
...
...
tests/lib/Doctrine_OrmTestCase.php
View file @
6be6f40e
...
...
@@ -15,7 +15,7 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
if
(
isset
(
$this
->
sharedFixture
[
'em'
]))
{
$this
->
_em
=
$this
->
sharedFixture
[
'em'
];
}
else
{
$config
=
new
Doctrine_
Common
_Configuration
();
$config
=
new
Doctrine_
ORM
_Configuration
();
$eventManager
=
new
Doctrine_Common_EventManager
();
$connectionOptions
=
array
(
'driverClass'
=>
'Doctrine_DriverMock'
,
...
...
tests/lib/Doctrine_OrmTestSuite.php
View file @
6be6f40e
...
...
@@ -10,7 +10,7 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
{
protected
function
setUp
()
{
$config
=
new
Doctrine_
Common
_Configuration
();
$config
=
new
Doctrine_
ORM
_Configuration
();
$eventManager
=
new
Doctrine_Common_EventManager
();
$connectionOptions
=
array
(
'driverClass'
=>
'Doctrine_DriverMock'
,
...
...
tests/lib/mocks/Doctrine_EntityManagerMock.php
View file @
6be6f40e
...
...
@@ -46,11 +46,11 @@ class Doctrine_EntityManagerMock extends Doctrine_ORM_EntityManager
* @param Doctrine_EventManager $eventManager
* @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
)
{
if
(
is_null
(
$config
))
{
$config
=
new
Doctrine_
Common
_Configuration
();
$config
=
new
Doctrine_
ORM
_Configuration
();
}
if
(
is_null
(
$eventManager
))
{
$eventManager
=
new
Doctrine_Common_EventManager
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment