Permalink
Browse files

[2.0] Fixed lifecycle callback mapping.

  • Loading branch information...
1 parent 356887c commit 8523648a27dfb36c471f394de7fb7de00b6f7fb5 romanb committed Aug 25, 2009
View
10 doctrine-mapping.xsd
@@ -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>
View
10 lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
@@ -275,12 +275,12 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
}
}
- // 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']));
}
}
}
View
8 lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
@@ -266,12 +266,12 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
}
}
- // 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));
}
}
}
View
8 tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml
@@ -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"/>
View
2 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml
@@ -32,6 +32,6 @@ Doctrine\Tests\ORM\Mapping\User:
inverseJoinColumns:
group_id:
referencedColumnName: id
- lifecycleListeners:
+ lifecycleCallbacks:
doStuffOnPrePersist: prePersist
doStuffOnPostPersist: postPersist

0 comments on commit 8523648

Please sign in to comment.