1
0
mirror of synced 2024-12-05 03:06:05 +03:00

change xml driver to use <lifecycle-callback\>

This commit is contained in:
Fabio B. Silva 2012-08-21 21:01:08 -03:00 committed by fabio.silva
parent 6b7e588da5
commit 195b639344
5 changed files with 25 additions and 65 deletions

View File

@ -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 File

@ -562,10 +562,8 @@ class XmlDriver extends FileDriver
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 File

@ -23,7 +23,7 @@
<entity-listeners>
<entity-listener>
<pre-persist method="prePersistHandler"/>
<lifecycle-callback type="prePersist" method="prePersistHandler"/>
</entity-listener>
</entity-listeners>

View File

@ -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 File

@ -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>