Commit ae6e597d authored by romanb's avatar romanb

[2.0][DDC-311] Fixed.

parent 04832e27
......@@ -219,6 +219,7 @@ class ClassMetadataFactory
$class->setVersioned($parent->isVersioned);
$class->setVersionField($parent->versionField);
$class->setDiscriminatorMap($parent->discriminatorMap);
$class->setLifecycleCallbacks($parent->lifecycleCallbacks);
}
// Invoke driver
......
......@@ -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.
......
......@@ -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();
}
}
\ No newline at end of file
}
/** @MappedSuperclass @HasLifecycleCallbacks */
class LifecycleCallbackParentEntity {
/** @PrePersist */
function doStuff() {
}
}
/** @Entity @Table(name="lc_cb_childentity") */
class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity {
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
}
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