Commit da07bf4a authored by romanb's avatar romanb

[2.0] Small refactorings.

parent d674f192
...@@ -4,18 +4,11 @@ namespace Doctrine\Common; ...@@ -4,18 +4,11 @@ namespace Doctrine\Common;
class DoctrineException extends \Exception class DoctrineException extends \Exception
{ {
private $_innerException;
private static $_messages = array(); private static $_messages = array();
public function __construct($message = "", \Exception $innerException = null) public function __construct($message = "", \Exception $cause = null)
{ {
parent::__construct($message); parent::__construct($message, 0, $cause);
$this->_innerException = $innerException;
}
public function getInnerException()
{
return $this->_innerException;
} }
public static function notImplemented($method, $class) public static function notImplemented($method, $class)
......
...@@ -39,6 +39,11 @@ class EventArgs ...@@ -39,6 +39,11 @@ class EventArgs
{ {
private static $_emptyEventArgsInstance; private static $_emptyEventArgsInstance;
/**
* Gets the single, empty EventArgs instance.
*
* @return EventArgs
*/
public static function getEmptyInstance() public static function getEmptyInstance()
{ {
if ( ! self::$_emptyEventArgsInstance) { if ( ! self::$_emptyEventArgsInstance) {
......
...@@ -25,7 +25,7 @@ namespace Doctrine\Common; ...@@ -25,7 +25,7 @@ namespace Doctrine\Common;
* Contract for classes that provide the service of notifying listeners of * Contract for classes that provide the service of notifying listeners of
* changes to their properties. * changes to their properties.
* *
* @author robo * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
interface NotifyPropertyChanged interface NotifyPropertyChanged
...@@ -35,6 +35,6 @@ interface NotifyPropertyChanged ...@@ -35,6 +35,6 @@ interface NotifyPropertyChanged
* *
* @param PropertyChangedListener $listener * @param PropertyChangedListener $listener
*/ */
public function addPropertyChangedListener(PropertyChangedListener $listener); function addPropertyChangedListener(PropertyChangedListener $listener);
} }
...@@ -25,11 +25,11 @@ namespace Doctrine\Common; ...@@ -25,11 +25,11 @@ namespace Doctrine\Common;
* Contract for classes that are potential listeners of a <tt>NotifyPropertyChanged</tt> * Contract for classes that are potential listeners of a <tt>NotifyPropertyChanged</tt>
* implementor. * implementor.
* *
* @author robo * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
interface PropertyChangedListener interface PropertyChangedListener
{ {
public function propertyChanged($sender, $propertyName, $oldValue, $newValue); function propertyChanged($sender, $propertyName, $oldValue, $newValue);
} }
...@@ -309,8 +309,13 @@ class EntityManager ...@@ -309,8 +309,13 @@ class EntityManager
*/ */
public function getReference($entityName, $identifier) public function getReference($entityName, $identifier)
{ {
if ($this->_config->getAllowPartialObjects()) {
$entity = new $entityName; $entity = new $entityName;
$this->getClassMetadata($entityName)->setEntityIdentifier($entity, $identifier); $this->getClassMetadata($entityName)->setEntityIdentifier($entity, $identifier);
} else {
$entity = $this->_proxyFactory->getReferenceProxy($entityName, $identifier);
}
return $entity; return $entity;
} }
...@@ -321,23 +326,12 @@ class EntityManager ...@@ -321,23 +326,12 @@ class EntityManager
*/ */
public function setFlushMode($flushMode) public function setFlushMode($flushMode)
{ {
if ( ! $this->_isFlushMode($flushMode)) { if ( ! ($flushMode >= 1 && $flushMode <= 4)) {
throw EntityManagerException::invalidFlushMode(); throw EntityManagerException::invalidFlushMode();
} }
$this->_flushMode = $flushMode; $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. * Gets the currently used flush mode.
* *
......
...@@ -33,42 +33,42 @@ final class Events ...@@ -33,42 +33,42 @@ final class Events
{ {
private function __construct() {} private function __construct() {}
/** /**
* The preDelete event occurs for a given entity before the respective * The preRemove event occurs for a given entity before the respective
* EntityManager delete operation for that entity is executed. * EntityManager remove operation for that entity is executed.
* *
* This is an entity lifecycle event. * This is an entity lifecycle event.
* *
* @var string * @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. * been deleted. It will be invoked after the database delete operations.
* *
* This is an entity lifecycle event. * This is an entity lifecycle event.
* *
* @var string * @var string
*/ */
const postDelete = 'postDelete'; const postRemove = 'postRemove';
/** /**
* The preSave event occurs for a given entity before the respective * The prePersist event occurs for a given entity before the respective
* EntityManager save operation for that entity is executed. * EntityManager persist operation for that entity is executed.
* *
* This is an entity lifecycle event. * This is an entity lifecycle event.
* *
* @var string * @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. * 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. * This is an entity lifecycle event.
* *
* @var string * @var string
*/ */
const postSave = 'postSave'; const postPersist = 'postPersist';
/** /**
* The preUpdate event occurs before the database update operations to * The preUpdate event occurs before the database update operations to
* entity data. * entity data.
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
namespace Doctrine\ORM\Mapping; namespace Doctrine\ORM\Mapping;
use \ReflectionClass;
use Doctrine\Common\DoctrineException; use Doctrine\Common\DoctrineException;
/** /**
...@@ -261,7 +260,7 @@ final class ClassMetadata ...@@ -261,7 +260,7 @@ final class ClassMetadata
* *
* @var boolean * @var boolean
*/ */
public $joinSubclasses = true; //public $joinSubclasses = true;
/** /**
* The discriminator value of this class. * The discriminator value of this class.
...@@ -288,7 +287,6 @@ final class ClassMetadata ...@@ -288,7 +287,6 @@ final class ClassMetadata
* *
* name => <tableName> * name => <tableName>
* schema => <schemaName> * schema => <schemaName>
* catalog => <catalogName> //TODO: remove catalog? needed?
* *
* @var array * @var array
*/ */
...@@ -408,7 +406,7 @@ final class ClassMetadata ...@@ -408,7 +406,7 @@ final class ClassMetadata
$this->namespace = substr($entityName, 0, strrpos($entityName, '\\')); $this->namespace = substr($entityName, 0, strrpos($entityName, '\\'));
$this->primaryTable['name'] = str_replace($this->namespace . '\\', '', $this->name); $this->primaryTable['name'] = str_replace($this->namespace . '\\', '', $this->name);
$this->rootEntityName = $entityName; $this->rootEntityName = $entityName;
$this->reflClass = new ReflectionClass($entityName); $this->reflClass = new \ReflectionClass($entityName);
} }
/** /**
......
...@@ -58,14 +58,19 @@ class AnnotationDriver implements Driver ...@@ -58,14 +58,19 @@ class AnnotationDriver implements Driver
{ {
$class = $metadata->getReflectionClass(); $class = $metadata->getReflectionClass();
$classAnnotations = $this->_reader->getClassAnnotations($class);
// Evaluate DoctrineEntity annotation // 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."); throw DoctrineException::updateMe("$className is no entity.");
} }
$entityAnnot = $classAnnotations['Doctrine\ORM\Mapping\Entity'];
$metadata->setCustomRepositoryClass($entityAnnot->repositoryClass); $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
// Evaluate DoctrineTable annotation // 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( $metadata->setPrimaryTable(array(
'name' => $tableAnnot->name, 'name' => $tableAnnot->name,
'schema' => $tableAnnot->schema 'schema' => $tableAnnot->schema
...@@ -73,12 +78,14 @@ class AnnotationDriver implements Driver ...@@ -73,12 +78,14 @@ class AnnotationDriver implements Driver
} }
// Evaluate InheritanceType annotation // 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)); $metadata->setInheritanceType(constant('\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
} }
// Evaluate DiscriminatorColumn annotation // 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( $metadata->setDiscriminatorColumn(array(
'name' => $discrColumnAnnot->name, 'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type, 'type' => $discrColumnAnnot->type,
...@@ -87,17 +94,20 @@ class AnnotationDriver implements Driver ...@@ -87,17 +94,20 @@ class AnnotationDriver implements Driver
} }
// Evaluate DiscriminatorValue annotation // 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); $metadata->setDiscriminatorValue($discrValueAnnot->value);
} }
// Evaluate DoctrineSubClasses annotation // 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); $metadata->setSubclasses($subClassesAnnot->value);
} }
// Evaluate DoctrineChangeTrackingPolicy annotation // 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); $metadata->setChangeTrackingPolicy($changeTrackingAnnot->value);
} }
...@@ -237,15 +247,16 @@ class AnnotationDriver implements Driver ...@@ -237,15 +247,16 @@ class AnnotationDriver implements Driver
} }
// Evaluate LifecycleListener annotation // 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) { foreach ($class->getMethods() as $method) {
if ($method->isPublic()) { if ($method->isPublic()) {
$annotations = $this->_reader->getMethodAnnotations($method); $annotations = $this->_reader->getMethodAnnotations($method);
if (isset($annotations['Doctrine\ORM\Mapping\PreSave'])) { if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preSave); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostSave'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postSave); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) { if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate);
...@@ -253,11 +264,11 @@ class AnnotationDriver implements Driver ...@@ -253,11 +264,11 @@ class AnnotationDriver implements Driver
if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PreDelete'])) { if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preDelete); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostDelete'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postDelete); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad);
...@@ -265,7 +276,6 @@ class AnnotationDriver implements Driver ...@@ -265,7 +276,6 @@ class AnnotationDriver implements Driver
} }
} }
} }
} }
/** /**
...@@ -278,10 +288,9 @@ class AnnotationDriver implements Driver ...@@ -278,10 +288,9 @@ class AnnotationDriver implements Driver
*/ */
public function isTransient($className) public function isTransient($className)
{ {
$refClass = new \ReflectionClass($className); $classAnnotations = $this->_reader->getClassAnnotations(new \ReflectionClass($className));
$docComment = $refClass->getDocComment(); return ! isset($classAnnotations['Doctrine\ORM\Mapping\Entity']) &&
return strpos($docComment, 'Entity') === false && ! isset($classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass']);
strpos($docComment, 'MappedSuperclass') === false;
} }
public function preload() public function preload()
......
...@@ -108,12 +108,12 @@ final class ChangeTrackingPolicy extends \Doctrine\Common\Annotations\Annotation ...@@ -108,12 +108,12 @@ final class ChangeTrackingPolicy extends \Doctrine\Common\Annotations\Annotation
/* Annotations for lifecycle callbacks */ /* Annotations for lifecycle callbacks */
final class LifecycleListener extends \Doctrine\Common\Annotations\Annotation {} final class LifecycleListener extends \Doctrine\Common\Annotations\Annotation {}
final class PreSave extends \Doctrine\Common\Annotations\Annotation {} final class PrePersist extends \Doctrine\Common\Annotations\Annotation {}
final class PostSave extends \Doctrine\Common\Annotations\Annotation {} final class PostPersist extends \Doctrine\Common\Annotations\Annotation {}
final class PreUpdate extends \Doctrine\Common\Annotations\Annotation {} final class PreUpdate extends \Doctrine\Common\Annotations\Annotation {}
final class PostUpdate extends \Doctrine\Common\Annotations\Annotation {} final class PostUpdate extends \Doctrine\Common\Annotations\Annotation {}
final class PreDelete extends \Doctrine\Common\Annotations\Annotation {} final class PreRemove extends \Doctrine\Common\Annotations\Annotation {}
final class PostDelete extends \Doctrine\Common\Annotations\Annotation {} final class PostRemove extends \Doctrine\Common\Annotations\Annotation {}
final class PostLoad extends \Doctrine\Common\Annotations\Annotation {} final class PostLoad extends \Doctrine\Common\Annotations\Annotation {}
/* Generic annotation for Doctrine extensions */ /* Generic annotation for Doctrine extensions */
......
...@@ -448,6 +448,7 @@ class StandardEntityPersister ...@@ -448,6 +448,7 @@ class StandardEntityPersister
} }
} else { } else {
// Inject collection // Inject collection
//TODO: Eager load
$this->_class->reflFields[$field]->setValue( $this->_class->reflFields[$field]->setValue(
$entity, new PersistentCollection($this->_em, $this->_em->getClassMetadata($assoc->targetEntityName) $entity, new PersistentCollection($this->_em, $this->_em->getClassMetadata($assoc->targetEntityName)
)); ));
......
...@@ -322,6 +322,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -322,6 +322,7 @@ class UnitOfWork implements PropertyChangedListener
$conn->commit(); $conn->commit();
} catch (\Exception $e) { } catch (\Exception $e) {
$conn->rollback(); $conn->rollback();
$this->clear();
throw $e; throw $e;
} }
...@@ -342,6 +343,9 @@ class UnitOfWork implements PropertyChangedListener ...@@ -342,6 +343,9 @@ class UnitOfWork implements PropertyChangedListener
$this->_orphanRemovals = array(); $this->_orphanRemovals = array();
} }
/**
* Executes any extra updates that have been scheduled.
*/
private function _executeExtraUpdates() private function _executeExtraUpdates()
{ {
foreach ($this->_extraUpdates as $oid => $update) { foreach ($this->_extraUpdates as $oid => $update) {
...@@ -659,8 +663,8 @@ class UnitOfWork implements PropertyChangedListener ...@@ -659,8 +663,8 @@ class UnitOfWork implements PropertyChangedListener
$className = $class->name; $className = $class->name;
$persister = $this->getEntityPersister($className); $persister = $this->getEntityPersister($className);
$hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postSave]); $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]);
$hasListeners = $this->_evm->hasListeners(Events::postSave); $hasListeners = $this->_evm->hasListeners(Events::postPersist);
if ($hasLifecycleCallbacks || $hasListeners) { if ($hasLifecycleCallbacks || $hasListeners) {
$entities = array(); $entities = array();
} }
...@@ -693,10 +697,10 @@ class UnitOfWork implements PropertyChangedListener ...@@ -693,10 +697,10 @@ class UnitOfWork implements PropertyChangedListener
if ($hasLifecycleCallbacks || $hasListeners) { if ($hasLifecycleCallbacks || $hasListeners) {
foreach ($entities as $entity) { foreach ($entities as $entity) {
if ($hasLifecycleCallbacks) { if ($hasLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::postSave, $entity); $class->invokeLifecycleCallbacks(Events::postPersist, $entity);
} }
if ($hasListeners) { 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 ...@@ -755,8 +759,8 @@ class UnitOfWork implements PropertyChangedListener
$className = $class->name; $className = $class->name;
$persister = $this->getEntityPersister($className); $persister = $this->getEntityPersister($className);
$hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postDelete]); $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postRemove]);
$hasListeners = $this->_evm->hasListeners(Events::postDelete); $hasListeners = $this->_evm->hasListeners(Events::postRemove);
foreach ($this->_entityDeletions as $oid => $entity) { foreach ($this->_entityDeletions as $oid => $entity) {
if (get_class($entity) == $className) { if (get_class($entity) == $className) {
...@@ -764,10 +768,10 @@ class UnitOfWork implements PropertyChangedListener ...@@ -764,10 +768,10 @@ class UnitOfWork implements PropertyChangedListener
unset($this->_entityDeletions[$oid]); unset($this->_entityDeletions[$oid]);
if ($hasLifecycleCallbacks) { if ($hasLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::postDelete, $entity); $class->invokeLifecycleCallbacks(Events::postRemove, $entity);
} }
if ($hasListeners) { 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 ...@@ -1162,11 +1166,11 @@ class UnitOfWork implements PropertyChangedListener
} }
break; break;
case self::STATE_NEW: case self::STATE_NEW:
if (isset($class->lifecycleCallbacks[Events::preSave])) { if (isset($class->lifecycleCallbacks[Events::prePersist])) {
$class->invokeLifecycleCallbacks(Events::preSave, $entity); $class->invokeLifecycleCallbacks(Events::prePersist, $entity);
} }
if ($this->_evm->hasListeners(Events::preSave)) { if ($this->_evm->hasListeners(Events::prePersist)) {
$this->_evm->dispatchEvent(Events::preSave, new LifecycleEventArgs($entity)); $this->_evm->dispatchEvent(Events::prePersist, new LifecycleEventArgs($entity));
} }
$idGen = $class->idGenerator; $idGen = $class->idGenerator;
...@@ -1237,11 +1241,11 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1237,11 +1241,11 @@ class UnitOfWork implements PropertyChangedListener
// nothing to do // nothing to do
break; break;
case self::STATE_MANAGED: case self::STATE_MANAGED:
if (isset($class->lifecycleCallbacks[Events::preDelete])) { if (isset($class->lifecycleCallbacks[Events::preRemove])) {
$class->invokeLifecycleCallbacks(Events::preDelete, $entity); $class->invokeLifecycleCallbacks(Events::preRemove, $entity);
} }
if ($this->_evm->hasListeners(Events::preDelete)) { if ($this->_evm->hasListeners(Events::preRemove)) {
$this->_evm->dispatchEvent(Events::preDelete, new LifecycleEventArgs($entity)); $this->_evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entity));
} }
$this->scheduleForDelete($entity); $this->scheduleForDelete($entity);
break; break;
...@@ -1483,19 +1487,19 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1483,19 +1487,19 @@ class UnitOfWork implements PropertyChangedListener
*/ */
public function clear() public function clear()
{ {
$this->_identityMap = array(); $this->_identityMap =
$this->_entityIdentifiers = array(); $this->_entityIdentifiers =
$this->_originalEntityData = array(); $this->_originalEntityData =
$this->_entityChangeSets = array(); $this->_entityChangeSets =
$this->_entityStates = array(); $this->_entityStates =
$this->_scheduledForDirtyCheck = array(); $this->_scheduledForDirtyCheck =
$this->_entityInsertions = array(); $this->_entityInsertions =
$this->_entityUpdates = array(); $this->_entityUpdates =
$this->_entityDeletions = array(); $this->_entityDeletions =
$this->_collectionDeletions = array(); $this->_collectionDeletions =
//$this->_collectionCreations = array(); //$this->_collectionCreations =
$this->_collectionUpdates = array(); $this->_collectionUpdates =
//$this->_orphanRemovals = array(); $this->_orphanRemovals = array();
$this->_commitOrderCalculator->clear(); $this->_commitOrderCalculator->clear();
} }
......
...@@ -17,7 +17,7 @@ class DoctrineExceptionTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -17,7 +17,7 @@ class DoctrineExceptionTest extends \Doctrine\Tests\DoctrineTestCase
{ {
$e1 = \Doctrine\Common\DoctrineException::testException(); $e1 = \Doctrine\Common\DoctrineException::testException();
$e2 = \Doctrine\Common\DoctrineException::testException2('param1', $e1); $e2 = \Doctrine\Common\DoctrineException::testException2('param1', $e1);
$this->assertEquals($e1, $e2->getInnerException()); $this->assertEquals($e1, $e2->getPrevious());
} }
public function testNotImplemented() public function testNotImplemented()
......
...@@ -24,8 +24,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -24,8 +24,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($entity); $this->_em->persist($entity);
$this->_em->flush(); $this->_em->flush();
$this->assertTrue($entity->preSaveCallbackInvoked); $this->assertTrue($entity->prePersistCallbackInvoked);
$this->assertTrue($entity->postSaveCallbackInvoked); $this->assertTrue($entity->postPersistCallbackInvoked);
$this->_em->clear(); $this->_em->clear();
...@@ -49,8 +49,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -49,8 +49,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
class LifecycleCallbackTestEntity class LifecycleCallbackTestEntity
{ {
/* test stuff */ /* test stuff */
public $preSaveCallbackInvoked = false; public $prePersistCallbackInvoked = false;
public $postSaveCallbackInvoked = false; public $postPersistCallbackInvoked = false;
public $postLoadCallbackInvoked = false; public $postLoadCallbackInvoked = false;
/** /**
...@@ -63,14 +63,14 @@ class LifecycleCallbackTestEntity ...@@ -63,14 +63,14 @@ class LifecycleCallbackTestEntity
*/ */
public $value; public $value;
/** @PreSave */ /** @PrePersist */
public function doStuffOnPreSave() { public function doStuffOnPrePersist() {
$this->preSaveCallbackInvoked = true; $this->prePersistCallbackInvoked = true;
} }
/** @PostSave */ /** @PostPersist */
public function doStuffOnPostSave() { public function doStuffOnPostPersist() {
$this->postSaveCallbackInvoked = true; $this->postPersistCallbackInvoked = true;
} }
/** @PostLoad */ /** @PostLoad */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment