From da07bf4a3743ad9b44acb12470c0fd5c4fbc9b5e Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 24 Jul 2009 11:33:38 +0000 Subject: [PATCH] [2.0] Small refactorings. --- lib/Doctrine/Common/DoctrineException.php | 11 +--- lib/Doctrine/Common/EventArgs.php | 7 +- lib/Doctrine/Common/NotifyPropertyChanged.php | 4 +- .../Common/PropertyChangedListener.php | 4 +- lib/Doctrine/ORM/EntityManager.php | 22 +++---- lib/Doctrine/ORM/Events.php | 22 +++---- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 6 +- .../ORM/Mapping/Driver/AnnotationDriver.php | 51 +++++++++------ .../Mapping/Driver/DoctrineAnnotations.php | 8 +-- .../Persisters/StandardEntityPersister.php | 1 + lib/Doctrine/ORM/UnitOfWork.php | 64 ++++++++++--------- .../Tests/Common/DoctrineExceptionTest.php | 2 +- .../ORM/Functional/LifecycleCallbackTest.php | 20 +++--- 13 files changed, 113 insertions(+), 109 deletions(-) diff --git a/lib/Doctrine/Common/DoctrineException.php b/lib/Doctrine/Common/DoctrineException.php index 97a00ae75..b8ca3bac6 100644 --- a/lib/Doctrine/Common/DoctrineException.php +++ b/lib/Doctrine/Common/DoctrineException.php @@ -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) diff --git a/lib/Doctrine/Common/EventArgs.php b/lib/Doctrine/Common/EventArgs.php index 0f0fe9b49..505f4b1dd 100644 --- a/lib/Doctrine/Common/EventArgs.php +++ b/lib/Doctrine/Common/EventArgs.php @@ -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) { diff --git a/lib/Doctrine/Common/NotifyPropertyChanged.php b/lib/Doctrine/Common/NotifyPropertyChanged.php index 4f3e942ee..84abfa8ea 100644 --- a/lib/Doctrine/Common/NotifyPropertyChanged.php +++ b/lib/Doctrine/Common/NotifyPropertyChanged.php @@ -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 * @since 2.0 */ interface NotifyPropertyChanged @@ -35,6 +35,6 @@ interface NotifyPropertyChanged * * @param PropertyChangedListener $listener */ - public function addPropertyChangedListener(PropertyChangedListener $listener); + function addPropertyChangedListener(PropertyChangedListener $listener); } diff --git a/lib/Doctrine/Common/PropertyChangedListener.php b/lib/Doctrine/Common/PropertyChangedListener.php index fc27a09fc..de83ce48a 100644 --- a/lib/Doctrine/Common/PropertyChangedListener.php +++ b/lib/Doctrine/Common/PropertyChangedListener.php @@ -25,11 +25,11 @@ namespace Doctrine\Common; * Contract for classes that are potential listeners of a NotifyPropertyChanged * implementor. * - * @author robo + * @author Roman Borschel * @since 2.0 */ interface PropertyChangedListener { - public function propertyChanged($sender, $propertyName, $oldValue, $newValue); + function propertyChanged($sender, $propertyName, $oldValue, $newValue); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index c77ffdcbb..65da137ea 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -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. * diff --git a/lib/Doctrine/ORM/Events.php b/lib/Doctrine/ORM/Events.php index 8667203a7..a90340932 100644 --- a/lib/Doctrine/ORM/Events.php +++ b/lib/Doctrine/ORM/Events.php @@ -33,42 +33,42 @@ final class Events { private function __construct() {} /** - * The preDelete event occurs for a given entity before the respective - * EntityManager delete operation for that entity is executed. + * The preRemove event occurs for a given entity before the respective + * EntityManager remove operation for that entity is executed. * * This is an entity lifecycle event. * * @var string */ - const preDelete = 'preDelete'; + const preRemove = 'preRemove'; /** - * The postDelete event occurs for an entity after the entity has + * The postRemove 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 postDelete = 'postDelete'; + const postRemove = 'postRemove'; /** - * The preSave event occurs for a given entity before the respective - * EntityManager save operation for that entity is executed. + * The prePersist 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 preSave = 'preSave'; + const prePersist = 'prePersist'; /** - * The postSave event occurs for an entity after the entity has + * The postPersist 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 postSave event. + * Generated primary key values are available in the postPersist event. * * This is an entity lifecycle event. * * @var string */ - const postSave = 'postSave'; + const postPersist = 'postPersist'; /** * The preUpdate event occurs before the database update operations to * entity data. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index f90134fac..097fd3563 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -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 => * schema => - * catalog => //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); } /** diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index f88fe7591..f259eb101 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -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\PreSave'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preSave); + if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) { + $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist); } - if (isset($annotations['Doctrine\ORM\Mapping\PostSave'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postSave); + if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) { + $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist); } 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\PreDelete'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preDelete); + if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) { + $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove); } - if (isset($annotations['Doctrine\ORM\Mapping\PostDelete'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postDelete); + if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) { + $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove); } 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() diff --git a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php index 1f0e11952..7285ccb4c 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php @@ -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 PreSave extends \Doctrine\Common\Annotations\Annotation {} -final class PostSave extends \Doctrine\Common\Annotations\Annotation {} +final class PrePersist extends \Doctrine\Common\Annotations\Annotation {} +final class PostPersist extends \Doctrine\Common\Annotations\Annotation {} final class PreUpdate extends \Doctrine\Common\Annotations\Annotation {} final class PostUpdate extends \Doctrine\Common\Annotations\Annotation {} -final class PreDelete extends \Doctrine\Common\Annotations\Annotation {} -final class PostDelete extends \Doctrine\Common\Annotations\Annotation {} +final class PreRemove extends \Doctrine\Common\Annotations\Annotation {} +final class PostRemove extends \Doctrine\Common\Annotations\Annotation {} final class PostLoad extends \Doctrine\Common\Annotations\Annotation {} /* Generic annotation for Doctrine extensions */ diff --git a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php index b3d418cef..bdd76fcf1 100644 --- a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php @@ -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) )); diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 4624dd2cb..892041135 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -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::postSave]); - $hasListeners = $this->_evm->hasListeners(Events::postSave); + $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]); + $hasListeners = $this->_evm->hasListeners(Events::postPersist); 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::postSave, $entity); + $class->invokeLifecycleCallbacks(Events::postPersist, $entity); } if ($hasListeners) { - $this->_evm->dispatchEvent(Events::postSave, new LifecycleEventArgs($entity)); + $this->_evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entity)); } } } @@ -755,8 +759,8 @@ class UnitOfWork implements PropertyChangedListener $className = $class->name; $persister = $this->getEntityPersister($className); - $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postDelete]); - $hasListeners = $this->_evm->hasListeners(Events::postDelete); + $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postRemove]); + $hasListeners = $this->_evm->hasListeners(Events::postRemove); 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::postDelete, $entity); + $class->invokeLifecycleCallbacks(Events::postRemove, $entity); } if ($hasListeners) { - $this->_evm->dispatchEvent(Events::postDelete, new LifecycleEventArgs($entity)); + $this->_evm->dispatchEvent(Events::postRemove, new LifecycleEventArgs($entity)); } } } @@ -1162,11 +1166,11 @@ class UnitOfWork implements PropertyChangedListener } break; case self::STATE_NEW: - if (isset($class->lifecycleCallbacks[Events::preSave])) { - $class->invokeLifecycleCallbacks(Events::preSave, $entity); + if (isset($class->lifecycleCallbacks[Events::prePersist])) { + $class->invokeLifecycleCallbacks(Events::prePersist, $entity); } - if ($this->_evm->hasListeners(Events::preSave)) { - $this->_evm->dispatchEvent(Events::preSave, new LifecycleEventArgs($entity)); + if ($this->_evm->hasListeners(Events::prePersist)) { + $this->_evm->dispatchEvent(Events::prePersist, 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::preDelete])) { - $class->invokeLifecycleCallbacks(Events::preDelete, $entity); + if (isset($class->lifecycleCallbacks[Events::preRemove])) { + $class->invokeLifecycleCallbacks(Events::preRemove, $entity); } - if ($this->_evm->hasListeners(Events::preDelete)) { - $this->_evm->dispatchEvent(Events::preDelete, new LifecycleEventArgs($entity)); + if ($this->_evm->hasListeners(Events::preRemove)) { + $this->_evm->dispatchEvent(Events::preRemove, 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(); } diff --git a/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php b/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php index 225b91ed4..6787b4b95 100644 --- a/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php +++ b/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php @@ -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->getInnerException()); + $this->assertEquals($e1, $e2->getPrevious()); } public function testNotImplemented() diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index 64ee830dd..95eaf6e15 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -24,8 +24,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($entity); $this->_em->flush(); - $this->assertTrue($entity->preSaveCallbackInvoked); - $this->assertTrue($entity->postSaveCallbackInvoked); + $this->assertTrue($entity->prePersistCallbackInvoked); + $this->assertTrue($entity->postPersistCallbackInvoked); $this->_em->clear(); @@ -49,8 +49,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase class LifecycleCallbackTestEntity { /* test stuff */ - public $preSaveCallbackInvoked = false; - public $postSaveCallbackInvoked = false; + public $prePersistCallbackInvoked = false; + public $postPersistCallbackInvoked = false; public $postLoadCallbackInvoked = false; /** @@ -63,14 +63,14 @@ class LifecycleCallbackTestEntity */ public $value; - /** @PreSave */ - public function doStuffOnPreSave() { - $this->preSaveCallbackInvoked = true; + /** @PrePersist */ + public function doStuffOnPrePersist() { + $this->prePersistCallbackInvoked = true; } - /** @PostSave */ - public function doStuffOnPostSave() { - $this->postSaveCallbackInvoked = true; + /** @PostPersist */ + public function doStuffOnPostPersist() { + $this->postPersistCallbackInvoked = true; } /** @PostLoad */