Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 02577ad

Browse files
Add possibility for a one-to-many configuration
1 parent a679d04 commit 02577ad

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Resources/xsl/doctrine-mapping.xsl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<xsl:apply-templates select='orm' mode='tableAttribute'/>
3434
<xsl:apply-templates select='fields/field'/>
3535
<xsl:apply-templates select='fields/field' mode='fieldEntityReference'/>
36+
<xsl:apply-templates select='orm/inverse-reference' mode='inverseReferences'/>
3637
</xsl:element>
3738
</xsl:template>
3839

@@ -203,6 +204,20 @@
203204
<xsl:element name='many-to-one' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
204205
<xsl:attribute name='field'><xsl:value-of select='@name'/></xsl:attribute>
205206
<xsl:attribute name='target-entity'><xsl:value-of select='substring(@datatype, 8)'/></xsl:attribute>
207+
<xsl:if test='/flexmodel/object[@name = substring(current()/@datatype, 8)]/orm/inverse-reference[@object = current()/parent::fields/parent::object/@name]/@name'>
208+
<xsl:attribute name='inversed-by'><xsl:value-of select='/flexmodel/object[@name = substring(current()/@datatype, 8)]/orm/inverse-reference[@object = current()/parent::fields/parent::object/@name]/@name'/></xsl:attribute>
209+
</xsl:if>
210+
</xsl:element>
211+
</xsl:template>
212+
213+
<!--
214+
Add inverse references if defined
215+
-->
216+
<xsl:template match='object/orm/inverse-reference' mode='inverseReferences'>
217+
<xsl:element name='one-to-many' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
218+
<xsl:attribute name='field'><xsl:value-of select='@name'/></xsl:attribute>
219+
<xsl:attribute name='target-entity'><xsl:value-of select='@object'/></xsl:attribute>
220+
<xsl:attribute name='mapped-by'><xsl:value-of select='@field'/></xsl:attribute>
206221
</xsl:element>
207222
</xsl:template>
208223

0 commit comments

Comments
 (0)