[2.0] Fixed lifecycle callback mapping.
This commit is contained in:
parent
356887c893
commit
8523648a27
@ -33,7 +33,7 @@
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:simpleType name="lifecycle-listener-type">
|
||||
<xs:simpleType name="lifecycle-callback-type">
|
||||
<xs:restriction base="xs:token">
|
||||
<xs:enumeration value="prePersist"/>
|
||||
<xs:enumeration value="postPersist"/>
|
||||
@ -45,14 +45,14 @@
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:complexType name="lifecycle-listener">
|
||||
<xs:attribute name="type" type="orm:lifecycle-listener-type" use="required" />
|
||||
<xs:complexType name="lifecycle-callback">
|
||||
<xs:attribute name="type" type="orm:lifecycle-callback-type" use="required" />
|
||||
<xs:attribute name="method" type="xs:NMTOKEN" use="required" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="lifecycle-listener">
|
||||
<xs:complexType name="lifecycle-callbacks">
|
||||
<xs:sequence>
|
||||
<xs:element name="lifecycle-listener" type="orm:lifecycle-listener" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xs:element name="lifecycle-callback" type="orm:lifecycle-callback" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
|
@ -275,12 +275,12 @@ class XmlDriver extends AbstractFileDriver
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate <lifecycle-listener...>
|
||||
if (isset($xmlRoot->{'lifecycle-listener'})) {
|
||||
foreach ($xmlRoot->{'lifecycle-listener'} as $lifecycleListener) {
|
||||
$method = $class->getMethod((string)$lifecycleListener['method']);
|
||||
// Evaluate <lifecycle-callbacks...>
|
||||
if (isset($xmlRoot->{'lifecycle-callbacks'})) {
|
||||
foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) {
|
||||
$method = $class->getMethod((string)$lifecycleCallback['method']);
|
||||
if ($method->isPublic()) {
|
||||
$metadata->addLifecycleCallback($method->getName(), constant('\Doctrine\ORM\Events::' . (string)$lifecycleListener['type']));
|
||||
$metadata->addLifecycleCallback($method->getName(), constant('\Doctrine\ORM\Events::' . (string)$lifecycleCallback['type']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,12 +266,12 @@ class YamlDriver extends AbstractFileDriver
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate lifeCycleListener
|
||||
if (isset($element['lifecycleListeners'])) {
|
||||
foreach ($element['lifecycleListeners'] as $method => $type) {
|
||||
// Evaluate lifeCycleCallbacks
|
||||
if (isset($element['lifecycleCallbacks'])) {
|
||||
foreach ($element['lifecycleCallbacks'] as $method => $type) {
|
||||
$method = $class->getMethod($method);
|
||||
if ($method->isPublic()) {
|
||||
$metadata->addLifecycleCallback($method->getName(), constant('\Doctrine\ORM\Events::'.$type));
|
||||
$metadata->addLifecycleCallback($method->getName(), constant('\Doctrine\ORM\Events::' . $type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,11 @@
|
||||
/Users/robo/dev/php/Doctrine/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users">
|
||||
|
||||
<lifecycle-listener method="doStuffOnPrePersist" type="prePersist" />
|
||||
<lifecycle-listener method="doStuffOnPostPersist" type="postPersist" />
|
||||
|
||||
<lifecycle-callbacks>
|
||||
<lifecycle-callback type="prePersist" method="doStuffOnPrePersist"/>
|
||||
<lifecycle-callback type="postPersist" method="doStuffOnPostPersist"/>
|
||||
</lifecycle-callbacks>
|
||||
|
||||
<id name="id" type="integer" column="id">
|
||||
<generator strategy="AUTO"/>
|
||||
|
@ -32,6 +32,6 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
inverseJoinColumns:
|
||||
group_id:
|
||||
referencedColumnName: id
|
||||
lifecycleListeners:
|
||||
lifecycleCallbacks:
|
||||
doStuffOnPrePersist: prePersist
|
||||
doStuffOnPostPersist: postPersist
|
Loading…
Reference in New Issue
Block a user