[2.0][DDC-311] Fixed.
This commit is contained in:
parent
04832e2789
commit
ae6e597dca
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @MappedSuperclass @HasLifecycleCallbacks */
|
||||
class LifecycleCallbackParentEntity {
|
||||
/** @PrePersist */
|
||||
function doStuff() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** @Entity @Table(name="lc_cb_childentity") */
|
||||
class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity {
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
private $id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user