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
da07bf4a
Commit
da07bf4a
authored
Jul 24, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Small refactorings.
parent
d674f192
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
113 additions
and
109 deletions
+113
-109
DoctrineException.php
lib/Doctrine/Common/DoctrineException.php
+2
-9
EventArgs.php
lib/Doctrine/Common/EventArgs.php
+6
-1
NotifyPropertyChanged.php
lib/Doctrine/Common/NotifyPropertyChanged.php
+2
-2
PropertyChangedListener.php
lib/Doctrine/Common/PropertyChangedListener.php
+2
-2
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+8
-14
Events.php
lib/Doctrine/ORM/Events.php
+11
-11
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+2
-4
AnnotationDriver.php
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
+30
-21
DoctrineAnnotations.php
lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
+4
-4
StandardEntityPersister.php
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
+1
-0
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+34
-30
DoctrineExceptionTest.php
tests/Doctrine/Tests/Common/DoctrineExceptionTest.php
+1
-1
LifecycleCallbackTest.php
...s/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
+10
-10
No files found.
lib/Doctrine/Common/DoctrineException.php
View file @
da07bf4a
...
...
@@ -4,18 +4,11 @@ namespace Doctrine\Common;
class
DoctrineException
extends
\Exception
{
private
$_innerException
;
private
static
$_messages
=
array
();
public
function
__construct
(
$message
=
""
,
\Exception
$
innerException
=
null
)
public
function
__construct
(
$message
=
""
,
\Exception
$
cause
=
null
)
{
parent
::
__construct
(
$message
);
$this
->
_innerException
=
$innerException
;
}
public
function
getInnerException
()
{
return
$this
->
_innerException
;
parent
::
__construct
(
$message
,
0
,
$cause
);
}
public
static
function
notImplemented
(
$method
,
$class
)
...
...
lib/Doctrine/Common/EventArgs.php
View file @
da07bf4a
...
...
@@ -38,7 +38,12 @@ namespace Doctrine\Common;
class
EventArgs
{
private
static
$_emptyEventArgsInstance
;
/**
* Gets the single, empty EventArgs instance.
*
* @return EventArgs
*/
public
static
function
getEmptyInstance
()
{
if
(
!
self
::
$_emptyEventArgsInstance
)
{
...
...
lib/Doctrine/Common/NotifyPropertyChanged.php
View file @
da07bf4a
...
...
@@ -25,7 +25,7 @@ namespace Doctrine\Common;
* Contract for classes that provide the service of notifying listeners of
* changes to their properties.
*
* @author
robo
* @author
Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
interface
NotifyPropertyChanged
...
...
@@ -35,6 +35,6 @@ interface NotifyPropertyChanged
*
* @param PropertyChangedListener $listener
*/
public
function
addPropertyChangedListener
(
PropertyChangedListener
$listener
);
function
addPropertyChangedListener
(
PropertyChangedListener
$listener
);
}
lib/Doctrine/Common/PropertyChangedListener.php
View file @
da07bf4a
...
...
@@ -25,11 +25,11 @@ namespace Doctrine\Common;
* Contract for classes that are potential listeners of a <tt>NotifyPropertyChanged</tt>
* implementor.
*
* @author
robo
* @author
Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
interface
PropertyChangedListener
{
public
function
propertyChanged
(
$sender
,
$propertyName
,
$oldValue
,
$newValue
);
function
propertyChanged
(
$sender
,
$propertyName
,
$oldValue
,
$newValue
);
}
lib/Doctrine/ORM/EntityManager.php
View file @
da07bf4a
...
...
@@ -309,8 +309,13 @@ class EntityManager
*/
public
function
getReference
(
$entityName
,
$identifier
)
{
$entity
=
new
$entityName
;
$this
->
getClassMetadata
(
$entityName
)
->
setEntityIdentifier
(
$entity
,
$identifier
);
if
(
$this
->
_config
->
getAllowPartialObjects
())
{
$entity
=
new
$entityName
;
$this
->
getClassMetadata
(
$entityName
)
->
setEntityIdentifier
(
$entity
,
$identifier
);
}
else
{
$entity
=
$this
->
_proxyFactory
->
getReferenceProxy
(
$entityName
,
$identifier
);
}
return
$entity
;
}
...
...
@@ -321,23 +326,12 @@ class EntityManager
*/
public
function
setFlushMode
(
$flushMode
)
{
if
(
!
$this
->
_isFlushMode
(
$flushMode
))
{
if
(
!
(
$flushMode
>=
1
&&
$flushMode
<=
4
))
{
throw
EntityManagerException
::
invalidFlushMode
();
}
$this
->
_flushMode
=
$flushMode
;
}
/**
* Checks whether the given value is a valid flush mode.
*
* @param string $value
* @return boolean
*/
private
function
_isFlushMode
(
$value
)
{
return
$value
>=
1
&&
$value
<=
4
;
}
/**
* Gets the currently used flush mode.
*
...
...
lib/Doctrine/ORM/Events.php
View file @
da07bf4a
...
...
@@ -33,42 +33,42 @@ final class Events
{
private
function
__construct
()
{}
/**
* The pre
Delet
e event occurs for a given entity before the respective
* EntityManager
delet
e operation for that entity is executed.
* The pre
Remov
e event occurs for a given entity before the respective
* EntityManager
remov
e operation for that entity is executed.
*
* This is an entity lifecycle event.
*
* @var string
*/
const
pre
Delete
=
'preDelet
e'
;
const
pre
Remove
=
'preRemov
e'
;
/**
* The post
Delet
e event occurs for an entity after the entity has
* The post
Remov
e event occurs for an entity after the entity has
* been deleted. It will be invoked after the database delete operations.
*
* This is an entity lifecycle event.
*
* @var string
*/
const
post
Delete
=
'postDelet
e'
;
const
post
Remove
=
'postRemov
e'
;
/**
* The pre
Save
event occurs for a given entity before the respective
* EntityManager
save
operation for that entity is executed.
* The pre
Persist
event occurs for a given entity before the respective
* EntityManager
persist
operation for that entity is executed.
*
* This is an entity lifecycle event.
*
* @var string
*/
const
pre
Save
=
'preSave
'
;
const
pre
Persist
=
'prePersist
'
;
/**
* The post
Save
event occurs for an entity after the entity has
* The post
Persist
event occurs for an entity after the entity has
* been made persistent. It will be invoked after the database insert operations.
* Generated primary key values are available in the post
Save
event.
* Generated primary key values are available in the post
Persist
event.
*
* This is an entity lifecycle event.
*
* @var string
*/
const
post
Save
=
'postSave
'
;
const
post
Persist
=
'postPersist
'
;
/**
* The preUpdate event occurs before the database update operations to
* entity data.
...
...
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
da07bf4a
...
...
@@ -21,7 +21,6 @@
namespace
Doctrine\ORM\Mapping
;
use
\ReflectionClass
;
use
Doctrine\Common\DoctrineException
;
/**
...
...
@@ -261,7 +260,7 @@ final class ClassMetadata
*
* @var boolean
*/
public
$joinSubclasses
=
true
;
//
public $joinSubclasses = true;
/**
* The discriminator value of this class.
...
...
@@ -288,7 +287,6 @@ final class ClassMetadata
*
* name => <tableName>
* schema => <schemaName>
* catalog => <catalogName> //TODO: remove catalog? needed?
*
* @var array
*/
...
...
@@ -408,7 +406,7 @@ final class ClassMetadata
$this
->
namespace
=
substr
(
$entityName
,
0
,
strrpos
(
$entityName
,
'\\'
));
$this
->
primaryTable
[
'name'
]
=
str_replace
(
$this
->
namespace
.
'\\'
,
''
,
$this
->
name
);
$this
->
rootEntityName
=
$entityName
;
$this
->
reflClass
=
new
ReflectionClass
(
$entityName
);
$this
->
reflClass
=
new
\
ReflectionClass
(
$entityName
);
}
/**
...
...
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
View file @
da07bf4a
...
...
@@ -57,15 +57,20 @@ class AnnotationDriver implements Driver
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
$metadata
)
{
$class
=
$metadata
->
getReflectionClass
();
$classAnnotations
=
$this
->
_reader
->
getClassAnnotations
(
$class
);
// Evaluate DoctrineEntity annotation
if
(
(
$entityAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\Entity'
))
===
null
)
{
if
(
!
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\Entity'
])
)
{
throw
DoctrineException
::
updateMe
(
"
$className
is no entity."
);
}
$entityAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\Entity'
];
$metadata
->
setCustomRepositoryClass
(
$entityAnnot
->
repositoryClass
);
// Evaluate DoctrineTable annotation
if
(
$tableAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\Table'
))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\Table'
]))
{
$tableAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\Table'
];
$metadata
->
setPrimaryTable
(
array
(
'name'
=>
$tableAnnot
->
name
,
'schema'
=>
$tableAnnot
->
schema
...
...
@@ -73,12 +78,14 @@ class AnnotationDriver implements Driver
}
// Evaluate InheritanceType annotation
if
(
$inheritanceTypeAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\InheritanceType'
))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\InheritanceType'
]))
{
$inheritanceTypeAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\InheritanceType'
];
$metadata
->
setInheritanceType
(
constant
(
'\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_'
.
$inheritanceTypeAnnot
->
value
));
}
// Evaluate DiscriminatorColumn annotation
if
(
$discrColumnAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\DiscriminatorColumn'
))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\DiscriminatorColumn'
]))
{
$discrColumnAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\DiscriminatorColumn'
];
$metadata
->
setDiscriminatorColumn
(
array
(
'name'
=>
$discrColumnAnnot
->
name
,
'type'
=>
$discrColumnAnnot
->
type
,
...
...
@@ -87,17 +94,20 @@ class AnnotationDriver implements Driver
}
// Evaluate DiscriminatorValue annotation
if
(
$discrValueAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\DiscriminatorValue'
))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\DiscriminatorValue'
]))
{
$discrValueAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\DiscriminatorValue'
];
$metadata
->
setDiscriminatorValue
(
$discrValueAnnot
->
value
);
}
// Evaluate DoctrineSubClasses annotation
if
(
$subClassesAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\SubClasses'
))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\SubClasses'
]))
{
$subClassesAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\SubClasses'
];
$metadata
->
setSubclasses
(
$subClassesAnnot
->
value
);
}
// Evaluate DoctrineChangeTrackingPolicy annotation
if
(
$changeTrackingAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\ChangeTrackingPolicy'
))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\ChangeTrackingPolicy'
]))
{
$changeTrackingAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\ChangeTrackingPolicy'
];
$metadata
->
setChangeTrackingPolicy
(
$changeTrackingAnnot
->
value
);
}
...
...
@@ -237,15 +247,16 @@ class AnnotationDriver implements Driver
}
// Evaluate LifecycleListener annotation
if
((
$lifecycleListenerAnnot
=
$this
->
_reader
->
getClassAnnotation
(
$class
,
'Doctrine\ORM\Mapping\LifecycleListener'
)))
{
if
(
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\LifecycleListener'
]))
{
$lifecycleListenerAnnot
=
$classAnnotations
[
'Doctrine\ORM\Mapping\LifecycleListener'
];
foreach
(
$class
->
getMethods
()
as
$method
)
{
if
(
$method
->
isPublic
())
{
$annotations
=
$this
->
_reader
->
getMethodAnnotations
(
$method
);
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Pre
Save
'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
pre
Save
);
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Pre
Persist
'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
pre
Persist
);
}
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Post
Save
'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
post
Save
);
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Post
Persist
'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
post
Persist
);
}
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\PreUpdate'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
preUpdate
);
...
...
@@ -253,11 +264,11 @@ class AnnotationDriver implements Driver
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\PostUpdate'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
postUpdate
);
}
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Pre
Delet
e'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
pre
Delet
e
);
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Pre
Remov
e'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
pre
Remov
e
);
}
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Post
Delet
e'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
post
Delet
e
);
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\Post
Remov
e'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
post
Remov
e
);
}
if
(
isset
(
$annotations
[
'Doctrine\ORM\Mapping\PostLoad'
]))
{
$metadata
->
addLifecycleCallback
(
$method
->
getName
(),
\Doctrine\ORM\Events
::
postLoad
);
...
...
@@ -265,7 +276,6 @@ class AnnotationDriver implements Driver
}
}
}
}
/**
...
...
@@ -278,10 +288,9 @@ class AnnotationDriver implements Driver
*/
public
function
isTransient
(
$className
)
{
$refClass
=
new
\ReflectionClass
(
$className
);
$docComment
=
$refClass
->
getDocComment
();
return
strpos
(
$docComment
,
'Entity'
)
===
false
&&
strpos
(
$docComment
,
'MappedSuperclass'
)
===
false
;
$classAnnotations
=
$this
->
_reader
->
getClassAnnotations
(
new
\ReflectionClass
(
$className
));
return
!
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\Entity'
])
&&
!
isset
(
$classAnnotations
[
'Doctrine\ORM\Mapping\MappedSuperclass'
]);
}
public
function
preload
()
...
...
lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
View file @
da07bf4a
...
...
@@ -108,12 +108,12 @@ final class ChangeTrackingPolicy extends \Doctrine\Common\Annotations\Annotation
/* Annotations for lifecycle callbacks */
final
class
LifecycleListener
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Pre
Save
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Post
Save
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Pre
Persist
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Post
Persist
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
PreUpdate
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
PostUpdate
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Pre
Delet
e
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Post
Delet
e
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Pre
Remov
e
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
Post
Remov
e
extends
\Doctrine\Common\Annotations\Annotation
{}
final
class
PostLoad
extends
\Doctrine\Common\Annotations\Annotation
{}
/* Generic annotation for Doctrine extensions */
...
...
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
View file @
da07bf4a
...
...
@@ -448,6 +448,7 @@ class StandardEntityPersister
}
}
else
{
// Inject collection
//TODO: Eager load
$this
->
_class
->
reflFields
[
$field
]
->
setValue
(
$entity
,
new
PersistentCollection
(
$this
->
_em
,
$this
->
_em
->
getClassMetadata
(
$assoc
->
targetEntityName
)
));
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
da07bf4a
...
...
@@ -322,6 +322,7 @@ class UnitOfWork implements PropertyChangedListener
$conn
->
commit
();
}
catch
(
\Exception
$e
)
{
$conn
->
rollback
();
$this
->
clear
();
throw
$e
;
}
...
...
@@ -341,7 +342,10 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_visitedCollections
=
$this
->
_orphanRemovals
=
array
();
}
/**
* Executes any extra updates that have been scheduled.
*/
private
function
_executeExtraUpdates
()
{
foreach
(
$this
->
_extraUpdates
as
$oid
=>
$update
)
{
...
...
@@ -659,8 +663,8 @@ class UnitOfWork implements PropertyChangedListener
$className
=
$class
->
name
;
$persister
=
$this
->
getEntityPersister
(
$className
);
$hasLifecycleCallbacks
=
isset
(
$class
->
lifecycleCallbacks
[
Events
::
post
Save
]);
$hasListeners
=
$this
->
_evm
->
hasListeners
(
Events
::
post
Save
);
$hasLifecycleCallbacks
=
isset
(
$class
->
lifecycleCallbacks
[
Events
::
post
Persist
]);
$hasListeners
=
$this
->
_evm
->
hasListeners
(
Events
::
post
Persist
);
if
(
$hasLifecycleCallbacks
||
$hasListeners
)
{
$entities
=
array
();
}
...
...
@@ -693,10 +697,10 @@ class UnitOfWork implements PropertyChangedListener
if
(
$hasLifecycleCallbacks
||
$hasListeners
)
{
foreach
(
$entities
as
$entity
)
{
if
(
$hasLifecycleCallbacks
)
{
$class
->
invokeLifecycleCallbacks
(
Events
::
post
Save
,
$entity
);
$class
->
invokeLifecycleCallbacks
(
Events
::
post
Persist
,
$entity
);
}
if
(
$hasListeners
)
{
$this
->
_evm
->
dispatchEvent
(
Events
::
post
Save
,
new
LifecycleEventArgs
(
$entity
));
$this
->
_evm
->
dispatchEvent
(
Events
::
post
Persist
,
new
LifecycleEventArgs
(
$entity
));
}
}
}
...
...
@@ -755,8 +759,8 @@ class UnitOfWork implements PropertyChangedListener
$className
=
$class
->
name
;
$persister
=
$this
->
getEntityPersister
(
$className
);
$hasLifecycleCallbacks
=
isset
(
$class
->
lifecycleCallbacks
[
Events
::
post
Delet
e
]);
$hasListeners
=
$this
->
_evm
->
hasListeners
(
Events
::
post
Delet
e
);
$hasLifecycleCallbacks
=
isset
(
$class
->
lifecycleCallbacks
[
Events
::
post
Remov
e
]);
$hasListeners
=
$this
->
_evm
->
hasListeners
(
Events
::
post
Remov
e
);
foreach
(
$this
->
_entityDeletions
as
$oid
=>
$entity
)
{
if
(
get_class
(
$entity
)
==
$className
)
{
...
...
@@ -764,10 +768,10 @@ class UnitOfWork implements PropertyChangedListener
unset
(
$this
->
_entityDeletions
[
$oid
]);
if
(
$hasLifecycleCallbacks
)
{
$class
->
invokeLifecycleCallbacks
(
Events
::
post
Delet
e
,
$entity
);
$class
->
invokeLifecycleCallbacks
(
Events
::
post
Remov
e
,
$entity
);
}
if
(
$hasListeners
)
{
$this
->
_evm
->
dispatchEvent
(
Events
::
post
Delet
e
,
new
LifecycleEventArgs
(
$entity
));
$this
->
_evm
->
dispatchEvent
(
Events
::
post
Remov
e
,
new
LifecycleEventArgs
(
$entity
));
}
}
}
...
...
@@ -1162,11 +1166,11 @@ class UnitOfWork implements PropertyChangedListener
}
break
;
case
self
::
STATE_NEW
:
if
(
isset
(
$class
->
lifecycleCallbacks
[
Events
::
pre
Save
]))
{
$class
->
invokeLifecycleCallbacks
(
Events
::
pre
Save
,
$entity
);
if
(
isset
(
$class
->
lifecycleCallbacks
[
Events
::
pre
Persist
]))
{
$class
->
invokeLifecycleCallbacks
(
Events
::
pre
Persist
,
$entity
);
}
if
(
$this
->
_evm
->
hasListeners
(
Events
::
pre
Save
))
{
$this
->
_evm
->
dispatchEvent
(
Events
::
pre
Save
,
new
LifecycleEventArgs
(
$entity
));
if
(
$this
->
_evm
->
hasListeners
(
Events
::
pre
Persist
))
{
$this
->
_evm
->
dispatchEvent
(
Events
::
pre
Persist
,
new
LifecycleEventArgs
(
$entity
));
}
$idGen
=
$class
->
idGenerator
;
...
...
@@ -1237,11 +1241,11 @@ class UnitOfWork implements PropertyChangedListener
// nothing to do
break
;
case
self
::
STATE_MANAGED
:
if
(
isset
(
$class
->
lifecycleCallbacks
[
Events
::
pre
Delet
e
]))
{
$class
->
invokeLifecycleCallbacks
(
Events
::
pre
Delet
e
,
$entity
);
if
(
isset
(
$class
->
lifecycleCallbacks
[
Events
::
pre
Remov
e
]))
{
$class
->
invokeLifecycleCallbacks
(
Events
::
pre
Remov
e
,
$entity
);
}
if
(
$this
->
_evm
->
hasListeners
(
Events
::
pre
Delet
e
))
{
$this
->
_evm
->
dispatchEvent
(
Events
::
pre
Delet
e
,
new
LifecycleEventArgs
(
$entity
));
if
(
$this
->
_evm
->
hasListeners
(
Events
::
pre
Remov
e
))
{
$this
->
_evm
->
dispatchEvent
(
Events
::
pre
Remov
e
,
new
LifecycleEventArgs
(
$entity
));
}
$this
->
scheduleForDelete
(
$entity
);
break
;
...
...
@@ -1483,19 +1487,19 @@ class UnitOfWork implements PropertyChangedListener
*/
public
function
clear
()
{
$this
->
_identityMap
=
array
();
$this
->
_entityIdentifiers
=
array
();
$this
->
_originalEntityData
=
array
();
$this
->
_entityChangeSets
=
array
();
$this
->
_entityStates
=
array
();
$this
->
_scheduledForDirtyCheck
=
array
();
$this
->
_entityInsertions
=
array
();
$this
->
_entityUpdates
=
array
();
$this
->
_entityDeletions
=
array
();
$this
->
_collectionDeletions
=
array
();
//$this->_collectionCreations =
array();
$this
->
_collectionUpdates
=
array
();
//
$this->_orphanRemovals = array();
$this
->
_identityMap
=
$this
->
_entityIdentifiers
=
$this
->
_originalEntityData
=
$this
->
_entityChangeSets
=
$this
->
_entityStates
=
$this
->
_scheduledForDirtyCheck
=
$this
->
_entityInsertions
=
$this
->
_entityUpdates
=
$this
->
_entityDeletions
=
$this
->
_collectionDeletions
=
//$this->_collectionCreations =
$this
->
_collectionUpdates
=
$this
->
_orphanRemovals
=
array
();
$this
->
_commitOrderCalculator
->
clear
();
}
...
...
tests/Doctrine/Tests/Common/DoctrineExceptionTest.php
View file @
da07bf4a
...
...
@@ -17,7 +17,7 @@ class DoctrineExceptionTest extends \Doctrine\Tests\DoctrineTestCase
{
$e1
=
\Doctrine\Common\DoctrineException
::
testException
();
$e2
=
\Doctrine\Common\DoctrineException
::
testException2
(
'param1'
,
$e1
);
$this
->
assertEquals
(
$e1
,
$e2
->
get
InnerException
());
$this
->
assertEquals
(
$e1
,
$e2
->
get
Previous
());
}
public
function
testNotImplemented
()
...
...
tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
View file @
da07bf4a
...
...
@@ -24,8 +24,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
_em
->
persist
(
$entity
);
$this
->
_em
->
flush
();
$this
->
assertTrue
(
$entity
->
pre
Save
CallbackInvoked
);
$this
->
assertTrue
(
$entity
->
post
Save
CallbackInvoked
);
$this
->
assertTrue
(
$entity
->
pre
Persist
CallbackInvoked
);
$this
->
assertTrue
(
$entity
->
post
Persist
CallbackInvoked
);
$this
->
_em
->
clear
();
...
...
@@ -49,8 +49,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
class
LifecycleCallbackTestEntity
{
/* test stuff */
public
$pre
Save
CallbackInvoked
=
false
;
public
$post
Save
CallbackInvoked
=
false
;
public
$pre
Persist
CallbackInvoked
=
false
;
public
$post
Persist
CallbackInvoked
=
false
;
public
$postLoadCallbackInvoked
=
false
;
/**
...
...
@@ -63,14 +63,14 @@ class LifecycleCallbackTestEntity
*/
public
$value
;
/** @Pre
Save
*/
public
function
doStuffOnPre
Save
()
{
$this
->
pre
Save
CallbackInvoked
=
true
;
/** @Pre
Persist
*/
public
function
doStuffOnPre
Persist
()
{
$this
->
pre
Persist
CallbackInvoked
=
true
;
}
/** @Post
Save
*/
public
function
doStuffOnPost
Save
()
{
$this
->
post
Save
CallbackInvoked
=
true
;
/** @Post
Persist
*/
public
function
doStuffOnPost
Persist
()
{
$this
->
post
Persist
CallbackInvoked
=
true
;
}
/** @PostLoad */
...
...
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