Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change xml driver to use <lifecycle-callback\>

  • Loading branch information...
commit 195b63934458377554aa51eaa1a245177aad7850 1 parent 6b7e588
@FabioBatSilva authored fabio.silva committed
View
43 doctrine-mapping.xsd
@@ -98,50 +98,9 @@
</xs:sequence>
</xs:complexType>
- <xs:element name="query" type="xs:string"/>
-
- <xs:complexType name="pre-flush">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="post-load">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="pre-persist">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="post-persist">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="pre-update">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="post-update">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="pre-remove">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
- <xs:complexType name="post-remove">
- <xs:attribute name="method" type="xs:string"/>
- </xs:complexType>
-
<xs:complexType name="entity-listener">
<xs:sequence>
- <xs:element name="pre-flush" type="orm:pre-flush" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="post-load" type="orm:post-load" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="pre-persist" type="orm:pre-persist" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="post-persist" type="orm:post-persist" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="pre-update" type="orm:pre-update" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="post-update" type="orm:post-update" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="pre-remove" type="orm:pre-remove" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="post-remove" type="orm:post-remove" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="lifecycle-callback" type="orm:lifecycle-callback" minOccurs="0" maxOccurs="unbounded"/>
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="class" type="xs:string"/>
View
6 lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
@@ -562,10 +562,8 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
foreach ($xmlRoot->{'entity-listeners'}->{'entity-listener'} as $listenerElement) {
$listeners = array();
- foreach ($listenerElement as $type => $callbackElement) {
- list($prefix, $suffix) = explode('-', $type);
-
- $eventName = $prefix . ucfirst($suffix);
+ foreach ($listenerElement as $callbackElement) {
+ $eventName = (string) $callbackElement['type'];
$methodName = (string) $callbackElement['method'];
$listeners[] = array($eventName, $methodName);
View
2  tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml
@@ -23,7 +23,7 @@
<entity-listeners>
<entity-listener>
- <pre-persist method="prePersistHandler"/>
+ <lifecycle-callback type="prePersist" method="prePersistHandler"/>
</entity-listener>
</entity-listeners>
View
16 tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml
@@ -15,17 +15,17 @@
<entity-listeners>
<entity-listener class="CompanyContractListener">
- <pre-flush method="preFlushHandler"/>
- <post-load method="postLoadHandler"/>
+ <lifecycle-callback type="preFlush" method="preFlushHandler"/>
+ <lifecycle-callback type="postLoad" method="postLoadHandler"/>
- <post-persist method="postPersistHandler"/>
- <pre-persist method="prePersistHandler"/>
+ <lifecycle-callback type="postPersist" method="postPersistHandler"/>
+ <lifecycle-callback type="prePersist" method="prePersistHandler"/>
- <post-update method="postUpdateHandler"/>
- <pre-update method="preUpdateHandler"/>
+ <lifecycle-callback type="postUpdate" method="postUpdateHandler"/>
+ <lifecycle-callback type="preUpdate" method="preUpdateHandler"/>
- <post-remove method="postRemoveHandler"/>
- <pre-remove method="preRemoveHandler"/>
+ <lifecycle-callback type="postRemove" method="postRemoveHandler"/>
+ <lifecycle-callback type="preRemove" method="preRemoveHandler"/>
</entity-listener>
</entity-listeners>
View
23 ...rine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml
@@ -9,19 +9,22 @@
<entity-listeners>
<entity-listener class="CompanyContractListener">
- <pre-flush method="preFlushHandler"/>
- <post-load method="postLoadHandler"/>
- <pre-persist method="prePersistHandler"/>
- <post-persist method="postPersistHandler"/>
- <pre-update method="preUpdateHandler"/>
- <post-update method="postUpdateHandler"/>
- <pre-remove method="preRemoveHandler"/>
- <post-remove method="postRemoveHandler"/>
+ <lifecycle-callback type="preFlush" method="preFlushHandler"/>
+ <lifecycle-callback type="postLoad" method="postLoadHandler"/>
+
+ <lifecycle-callback type="postPersist" method="postPersistHandler"/>
+ <lifecycle-callback type="prePersist" method="prePersistHandler"/>
+
+ <lifecycle-callback type="postUpdate" method="postUpdateHandler"/>
+ <lifecycle-callback type="preUpdate" method="preUpdateHandler"/>
+
+ <lifecycle-callback type="postRemove" method="postRemoveHandler"/>
+ <lifecycle-callback type="preRemove" method="preRemoveHandler"/>
</entity-listener>
<entity-listener class="CompanyFlexUltraContractListener">
- <pre-persist method="prePersistHandler1"/>
- <pre-persist method="prePersistHandler2"/>
+ <lifecycle-callback type="prePersist" method="prePersistHandler1"/>
+ <lifecycle-callback type="prePersist" method="prePersistHandler2"/>
</entity-listener>
</entity-listeners>
Please sign in to comment.
Something went wrong with that request. Please try again.