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
d76096d0
Commit
d76096d0
authored
Jan 29, 2010
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-288] Removed deprecated flush modes.
parent
94d41dfb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
91 deletions
+14
-91
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+4
-75
ORMException.php
lib/Doctrine/ORM/ORMException.php
+10
-0
EntityManagerTest.php
tests/Doctrine/Tests/ORM/EntityManagerTest.php
+0
-16
No files found.
lib/Doctrine/ORM/EntityManager.php
View file @
d76096d0
...
...
@@ -41,31 +41,6 @@ use Doctrine\Common\EventManager,
*/
class
EntityManager
{
/**
* IMMEDIATE: Flush occurs automatically after each operation that issues database
* queries. No operations are queued.
* @deprecated
*/
const
FLUSHMODE_IMMEDIATE
=
1
;
/**
* AUTO: Flush occurs automatically in the following situations:
* - Before any query executions (to prevent getting stale data)
* - On EntityManager#commit()
* @deprecated
*/
const
FLUSHMODE_AUTO
=
2
;
/**
* COMMIT: Flush occurs automatically only on EntityManager#commit().
* @deprecated
*/
const
FLUSHMODE_COMMIT
=
3
;
/**
* MANUAL: Flush occurs never automatically. The only way to flush is
* through EntityManager#flush().
* @deprecated
*/
const
FLUSHMODE_MANUAL
=
4
;
/**
* The used Configuration.
*
...
...
@@ -94,14 +69,6 @@ class EntityManager
*/
private
$_repositories
=
array
();
/**
* The currently used flush mode. Defaults to 'commit'.
*
* @var string
* @deprecated
*/
private
$_flushMode
=
self
::
FLUSHMODE_COMMIT
;
/**
* The UnitOfWork used to coordinate object-level transactions.
*
...
...
@@ -187,15 +154,9 @@ class EntityManager
/**
* Commits a transaction on the underlying database connection.
*
* This causes a flush() of the EntityManager if the flush mode is set to
* AUTO or COMMIT.
*/
public
function
commit
()
{
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_AUTO
||
$this
->
_flushMode
==
self
::
FLUSHMODE_COMMIT
)
{
$this
->
flush
();
}
$this
->
_conn
->
commit
();
}
...
...
@@ -335,31 +296,6 @@ class EntityManager
return
$entity
;
}
/**
* Sets the flush mode to use.
*
* @param string $flushMode
* @deprecated
*/
public
function
setFlushMode
(
$flushMode
)
{
if
(
!
(
$flushMode
>=
1
&&
$flushMode
<=
4
))
{
throw
ORMException
::
invalidFlushMode
(
$flushMode
);
}
$this
->
_flushMode
=
$flushMode
;
}
/**
* Gets the currently used flush mode.
*
* @return string
* @deprecated
*/
public
function
getFlushMode
()
{
return
$this
->
_flushMode
;
}
/**
* Clears the EntityManager. All entities that are currently managed
* by this EntityManager become detached.
...
...
@@ -399,9 +335,6 @@ class EntityManager
{
$this
->
_errorIfClosed
();
$this
->
_unitOfWork
->
persist
(
$object
);
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_IMMEDIATE
)
{
$this
->
flush
();
}
}
/**
...
...
@@ -416,9 +349,6 @@ class EntityManager
{
$this
->
_errorIfClosed
();
$this
->
_unitOfWork
->
remove
(
$entity
);
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_IMMEDIATE
)
{
$this
->
flush
();
}
}
/**
...
...
@@ -470,8 +400,7 @@ class EntityManager
*/
public
function
copy
(
$entity
,
$deep
=
false
)
{
$this
->
_errorIfClosed
();
throw
DoctrineException
::
notImplemented
(
__FUNCTION__
,
__CLASS__
);
throw
new
\BadMethodCallException
(
"Not implemented."
);
}
/**
...
...
@@ -575,7 +504,7 @@ class EntityManager
$this
->
_hydrators
[
$hydrationMode
]
=
new
Internal\Hydration\SingleScalarHydrator
(
$this
);
break
;
default
:
throw
Doctrine
Exception
::
invalidHydrationMode
(
$hydrationMode
);
throw
ORM
Exception
::
invalidHydrationMode
(
$hydrationMode
);
}
}
return
$this
->
_hydrators
[
$hydrationMode
];
...
...
@@ -608,10 +537,10 @@ class EntityManager
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$conn
,
$config
,
(
$eventManager
?:
new
EventManager
()));
}
else
if
(
$conn
instanceof
Connection
)
{
if
(
$eventManager
!==
null
&&
$conn
->
getEventManager
()
!==
$eventManager
)
{
throw
DoctrineException
::
invalidEventManager
(
'Cannot use different EventManagers for EntityManager and Connection.'
);
throw
ORMException
::
mismatchedEventManager
(
);
}
}
else
{
throw
DoctrineException
::
invalidParameter
(
$conn
);
throw
new
\InvalidArgumentException
(
"Invalid argument: "
.
$conn
);
}
return
new
EntityManager
(
$conn
,
$config
,
$conn
->
getEventManager
());
...
...
lib/Doctrine/ORM/ORMException.php
View file @
d76096d0
...
...
@@ -46,4 +46,14 @@ class ORMException extends \Exception
{
return
new
self
(
"The EntityManager is closed."
);
}
public
static
function
invalidHydrationMode
(
$mode
)
{
return
new
self
(
"'
$mode
' is an invalid hydration mode."
);
}
public
static
function
mismatchedEventManager
()
{
return
new
self
(
"Cannot use different EventManager instances for EntityManager and Connection."
);
}
}
tests/Doctrine/Tests/ORM/EntityManagerTest.php
View file @
d76096d0
...
...
@@ -14,16 +14,6 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
$this
->
_em
=
$this
->
_getTestEntityManager
();
}
public
function
testSettingInvalidFlushModeThrowsException
()
{
$prev
=
$this
->
_em
->
getFlushMode
();
try
{
$this
->
_em
->
setFlushMode
(
'foobar'
);
$this
->
fail
(
"Setting invalid flushmode did not trigger exception."
);
}
catch
(
\Doctrine\ORM\ORMException
$expected
)
{}
$this
->
_em
->
setFlushMode
(
$prev
);
}
public
function
testGetConnection
()
{
$this
->
assertType
(
'\Doctrine\DBAL\Connection'
,
$this
->
_em
->
getConnection
());
...
...
@@ -54,11 +44,6 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
$this
->
assertType
(
'\Doctrine\Common\EventManager'
,
$this
->
_em
->
getEventManager
());
}
public
function
testGetDefaultFlushMode_OnCommit
()
{
$this
->
assertEquals
(
\Doctrine\ORM\EntityManager
::
FLUSHMODE_COMMIT
,
$this
->
_em
->
getFlushMode
());
}
public
function
testCreateNativeQuery
()
{
$rsm
=
new
\Doctrine\ORM\Query\ResultSetMapping
();
...
...
@@ -106,7 +91,6 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
array
(
'remove'
),
array
(
'merge'
),
array
(
'refresh'
),
array
(
'copy'
),
);
}
...
...
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