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

Commit 993bb72

Browse files
reyostallenbergniels-nijens
authored andcommitted
Also add default option to doctrine mappings when default_value is set (#59)
Add default_value of field to doctrine mapping
1 parent 55a2ba8 commit 993bb72

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Resources/xsl/doctrine-mapping.xsl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<xsl:apply-templates select='self::node()' mode='fieldLengthAttribute'/>
9797
<xsl:apply-templates select='self::node()' mode='fieldUniqueAttribute'/>
9898
<xsl:apply-templates select='self::node()' mode='fieldScalePrecisionAttribute'/>
99+
<xsl:apply-templates select='self::node()' mode='fieldOptions'/>
99100
</xsl:element>
100101
</xsl:template>
101102

@@ -187,6 +188,30 @@
187188
<xsl:attribute name='precision'><xsl:value-of select='@precision'/></xsl:attribute>
188189
</xsl:template>
189190

191+
<!--
192+
Don't add options by default.
193+
-->
194+
<xsl:template match='object/fields/field' mode='fieldOptions'/>
195+
196+
<!--
197+
Add options when default_value is set.
198+
-->
199+
<xsl:template match='object/fields/field[@default_value]' mode='fieldOptions'>
200+
<xsl:element name='options' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
201+
<xsl:apply-templates select='self::node()[@default_value]' mode='fieldOptionDefault'/>
202+
</xsl:element>
203+
</xsl:template>
204+
205+
<!--
206+
Add option for default.
207+
-->
208+
<xsl:template match='object/fields/field[@default_value]' mode='fieldOptionDefault'>
209+
<xsl:element name='option' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
210+
<xsl:attribute name='name'>default</xsl:attribute>
211+
<xsl:value-of select='@default_value'/>
212+
</xsl:element>
213+
</xsl:template>
214+
190215
<!--
191216
Don't add a field mapping when a field is defined in a orm/field-defined node or are an object reference.
192217
-->

0 commit comments

Comments
 (0)