1
0
mirror of synced 2024-12-12 22:36:02 +03:00

[2.0][DDC-311] Fixed.

This commit is contained in:
romanb 2010-02-10 22:17:43 +00:00
parent 04832e2789
commit ae6e597dca
3 changed files with 34 additions and 2 deletions

View File

@ -219,6 +219,7 @@ class ClassMetadataFactory
$class->setVersioned($parent->isVersioned);
$class->setVersionField($parent->versionField);
$class->setDiscriminatorMap($parent->discriminatorMap);
$class->setLifecycleCallbacks($parent->lifecycleCallbacks);
}
// Invoke driver

View File

@ -1371,6 +1371,17 @@ class ClassMetadataInfo
{
$this->lifecycleCallbacks[$event][] = $callback;
}
/**
* Sets the lifecycle callbacks for entities of this class.
* Any previously registered callbacks are overwritten.
*
* @param array $callbacks
*/
public function setLifecycleCallbacks(array $callbacks)
{
$this->lifecycleCallbacks = $callbacks;
}
/**
* Sets the discriminator column definition.

View File

@ -105,11 +105,17 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertTrue($e1->prePersistCallbackInvoked);
$this->assertTrue($e2->prePersistCallbackInvoked);
}
public function testLifecycleCallbacksGetInherited()
{
$childMeta = $this->_em->getClassMetadata(__NAMESPACE__ . '\LifecycleCallbackChildEntity');
$this->assertEquals(array('prePersist' => array(0 => 'doStuff')), $childMeta->lifecycleCallbacks);
}
}
/** @Entity @HasLifecycleCallbacks */
class LifecycleCallbackTestUser {
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
/** @Column(type="string") */
private $value;
@ -198,4 +204,18 @@ class LifecycleCallbackCascader
{
$this->entities = new \Doctrine\Common\Collections\ArrayCollection();
}
}
}
/** @MappedSuperclass @HasLifecycleCallbacks */
class LifecycleCallbackParentEntity {
/** @PrePersist */
function doStuff() {
}
}
/** @Entity @Table(name="lc_cb_childentity") */
class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity {
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
}