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
69a0b597
Commit
69a0b597
authored
Dec 02, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-174] Fixed.
parent
25c95885
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
ORMException.php
lib/Doctrine/ORM/ORMException.php
+10
-0
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+12
-12
No files found.
lib/Doctrine/ORM/ORMException.php
View file @
69a0b597
...
...
@@ -20,4 +20,14 @@ class ORMException extends \Exception
.
" detected in collection '"
.
$assoc
->
sourceFieldName
.
"' during flush."
.
" Remove deleted entities from collections."
);
}
public
static
function
invalidEntityState
(
$state
)
{
return
new
self
(
"Invalid entity state:
$state
."
);
}
public
static
function
detachedEntityCannotBeRemoved
()
{
return
new
self
(
"A detached entity can not be removed."
);
}
}
lib/Doctrine/ORM/UnitOfWork.php
View file @
69a0b597
...
...
@@ -854,13 +854,13 @@ class UnitOfWork implements PropertyChangedListener
$oid
=
spl_object_hash
(
$entity
);
if
(
isset
(
$this
->
_entityUpdates
[
$oid
]))
{
throw
DoctrineException
::
dirtyObjectCannotBeRegisteredAsNew
(
);
throw
new
\InvalidArgumentException
(
"Dirty entity can not be scheduled for insertion."
);
}
if
(
isset
(
$this
->
_entityDeletions
[
$oid
]))
{
throw
DoctrineException
::
removedObjectCannotBeRegisteredAsNew
(
);
throw
new
\InvalidArgumentException
(
"Removed entity can not be scheduled for insertion."
);
}
if
(
isset
(
$this
->
_entityInsertions
[
$oid
]))
{
throw
DoctrineException
::
objectAlreadyRegisteredAsNew
(
);
throw
new
\InvalidArgumentException
(
"Entity can not be scheduled for insertion twice."
);
}
$this
->
_entityInsertions
[
$oid
]
=
$entity
;
...
...
@@ -890,10 +890,10 @@ class UnitOfWork implements PropertyChangedListener
{
$oid
=
spl_object_hash
(
$entity
);
if
(
!
isset
(
$this
->
_entityIdentifiers
[
$oid
]))
{
throw
DoctrineException
::
entityWithoutIdentityCannotBeRegisteredAsDirty
(
);
throw
new
\InvalidArgumentException
(
"Entity has no identity."
);
}
if
(
isset
(
$this
->
_entityDeletions
[
$oid
]))
{
throw
DoctrineException
::
removedObjectCannotBeRegisteredAsDirty
(
);
throw
new
\InvalidArgumentException
(
"Entity is removed."
);
}
if
(
!
isset
(
$this
->
_entityUpdates
[
$oid
])
&&
!
isset
(
$this
->
_entityInsertions
[
$oid
]))
{
...
...
@@ -1009,7 +1009,7 @@ class UnitOfWork implements PropertyChangedListener
$classMetadata
=
$this
->
_em
->
getClassMetadata
(
get_class
(
$entity
));
$idHash
=
implode
(
' '
,
$this
->
_entityIdentifiers
[
spl_object_hash
(
$entity
)]);
if
(
$idHash
===
''
)
{
throw
DoctrineException
::
entityMustHaveIdentityToBeAddedToIdentityMap
(
$entity
);
throw
new
\InvalidArgumentException
(
"The given entity has no identity."
);
}
$className
=
$classMetadata
->
rootEntityName
;
if
(
isset
(
$this
->
_identityMap
[
$className
][
$idHash
]))
{
...
...
@@ -1072,7 +1072,7 @@ class UnitOfWork implements PropertyChangedListener
$classMetadata
=
$this
->
_em
->
getClassMetadata
(
get_class
(
$entity
));
$idHash
=
implode
(
' '
,
$this
->
_entityIdentifiers
[
$oid
]);
if
(
$idHash
===
''
)
{
throw
DoctrineException
::
entityMustHaveIdentifyToBeRemovedFromIdentityMap
(
$entity
);
throw
new
\InvalidArgumentException
(
"The given entity has no identity."
);
}
$className
=
$classMetadata
->
rootEntityName
;
if
(
isset
(
$this
->
_identityMap
[
$className
][
$idHash
]))
{
...
...
@@ -1212,8 +1212,8 @@ class UnitOfWork implements PropertyChangedListener
$this
->
scheduleForInsert
(
$entity
);
break
;
case
self
::
STATE_DETACHED
:
throw
DoctrineException
::
notImplemented
(
"Behavior of save() for a detached entity "
.
"
is not yet defined."
);
throw
new
\InvalidArgumentException
(
"Behavior of save() for a detached entity
is not yet defined."
);
case
self
::
STATE_REMOVED
:
// Entity becomes managed again
if
(
$this
->
isScheduledForDelete
(
$entity
))
{
...
...
@@ -1224,7 +1224,7 @@ class UnitOfWork implements PropertyChangedListener
}
break
;
default
:
throw
Doctrine
Exception
::
invalidEntityState
(
$entityState
);
throw
ORM
Exception
::
invalidEntityState
(
$entityState
);
}
$this
->
_cascadePersist
(
$entity
,
$visited
);
...
...
@@ -1277,9 +1277,9 @@ class UnitOfWork implements PropertyChangedListener
$this
->
scheduleForDelete
(
$entity
);
break
;
case
self
::
STATE_DETACHED
:
throw
Doctrine
Exception
::
detachedEntityCannotBeRemoved
();
throw
ORM
Exception
::
detachedEntityCannotBeRemoved
();
default
:
throw
Doctrine
Exception
::
invalidEntityState
(
$entityState
);
throw
ORM
Exception
::
invalidEntityState
(
$entityState
);
}
$this
->
_cascadeRemove
(
$entity
,
$visited
);
...
...
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