Commit 8523648a authored by romanb's avatar romanb

[2.0] Fixed lifecycle callback mapping.

parent 356887c8
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
<xs:simpleType name="lifecycle-listener-type"> <xs:simpleType name="lifecycle-callback-type">
<xs:restriction base="xs:token"> <xs:restriction base="xs:token">
<xs:enumeration value="prePersist"/> <xs:enumeration value="prePersist"/>
<xs:enumeration value="postPersist"/> <xs:enumeration value="postPersist"/>
...@@ -45,14 +45,14 @@ ...@@ -45,14 +45,14 @@
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:complexType name="lifecycle-listener"> <xs:complexType name="lifecycle-callback">
<xs:attribute name="type" type="orm:lifecycle-listener-type" use="required" /> <xs:attribute name="type" type="orm:lifecycle-callback-type" use="required" />
<xs:attribute name="method" type="xs:NMTOKEN" use="required" /> <xs:attribute name="method" type="xs:NMTOKEN" use="required" />
</xs:complexType> </xs:complexType>
<xs:complexType name="lifecycle-listener"> <xs:complexType name="lifecycle-callbacks">
<xs:sequence> <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:sequence>
</xs:complexType> </xs:complexType>
......
...@@ -275,12 +275,12 @@ class XmlDriver extends AbstractFileDriver ...@@ -275,12 +275,12 @@ class XmlDriver extends AbstractFileDriver
} }
} }
// Evaluate <lifecycle-listener...> // Evaluate <lifecycle-callbacks...>
if (isset($xmlRoot->{'lifecycle-listener'})) { if (isset($xmlRoot->{'lifecycle-callbacks'})) {
foreach ($xmlRoot->{'lifecycle-listener'} as $lifecycleListener) { foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) {
$method = $class->getMethod((string)$lifecycleListener['method']); $method = $class->getMethod((string)$lifecycleCallback['method']);
if ($method->isPublic()) { 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 ...@@ -266,12 +266,12 @@ class YamlDriver extends AbstractFileDriver
} }
} }
// Evaluate lifeCycleListener // Evaluate lifeCycleCallbacks
if (isset($element['lifecycleListeners'])) { if (isset($element['lifecycleCallbacks'])) {
foreach ($element['lifecycleListeners'] as $method => $type) { foreach ($element['lifecycleCallbacks'] as $method => $type) {
$method = $class->getMethod($method); $method = $class->getMethod($method);
if ($method->isPublic()) { 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 @@ ...@@ -6,9 +6,11 @@
/Users/robo/dev/php/Doctrine/doctrine-mapping.xsd"> /Users/robo/dev/php/Doctrine/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users"> <entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users">
<lifecycle-listener method="doStuffOnPrePersist" type="prePersist" /> <lifecycle-callbacks>
<lifecycle-listener method="doStuffOnPostPersist" type="postPersist" /> <lifecycle-callback type="prePersist" method="doStuffOnPrePersist"/>
<lifecycle-callback type="postPersist" method="doStuffOnPostPersist"/>
</lifecycle-callbacks>
<id name="id" type="integer" column="id"> <id name="id" type="integer" column="id">
<generator strategy="AUTO"/> <generator strategy="AUTO"/>
......
...@@ -32,6 +32,6 @@ Doctrine\Tests\ORM\Mapping\User: ...@@ -32,6 +32,6 @@ Doctrine\Tests\ORM\Mapping\User:
inverseJoinColumns: inverseJoinColumns:
group_id: group_id:
referencedColumnName: id referencedColumnName: id
lifecycleListeners: lifecycleCallbacks:
doStuffOnPrePersist: prePersist doStuffOnPrePersist: prePersist
doStuffOnPostPersist: postPersist doStuffOnPostPersist: postPersist
\ No newline at end of file
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