Skip to content

Commit c9ddb5f

Browse files
author
Caitlin Bales (MSFT)
committed
Add casting for set types
1 parent c6e6e45 commit c9ddb5f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Templates/PHP/Model/EntityType.php.tt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,19 @@ class <#=entity.Name.ToCheckedCase()#>
9292
/**
9393
* Sets the <#=property.Name#>
9494
*
95-
* @param string $val The <#=propertyName#>
95+
* @param string $val The <#=property.Name#>
9696
*
9797
* @return null
9898
*/
9999
public function set<#=property.Name.ToCheckedCase()#>($val)
100100
{
101-
$this->_propDict["<#=propertyName#>"] = $val;
101+
<# if (property.Type.GetTypeString() == "bool") { #>
102+
$this->propDict["<#=property.Name#>"] = boolval($val);
103+
<# } else if (property.Type.GetTypeString() == "int") { #>
104+
$this->propDict["<#=property.Name#>"] = intval($val);
105+
<# } else { #>
106+
$this->propDict["<#=property.Name#>"] = $val;
107+
<# } #>
102108
}
103109
<#
104110
}
@@ -132,7 +138,7 @@ class <#=entity.Name.ToCheckedCase()#>
132138
/**
133139
* Sets the <#=property.Name#>
134140
*
135-
* @param <#=property.Type.GetTypeString()#> $val The <#=propertyName#>
141+
* @param <#=property.Type.GetTypeString()#> $val The <#=property.Name#>
136142
*
137143
* @return null
138144
*/
@@ -145,7 +151,13 @@ class <#=entity.Name.ToCheckedCase()#>
145151
<#
146152
} else {
147153
#>
148-
$this->_propDict["<#=property.Name.ToCamelize()#>"] = $val;
154+
<# if (property.Type.GetTypeString() == "bool") { #>
155+
$this->propDict["<#=property.Name#>"] = boolval($val);
156+
<# } else if (property.Type.GetTypeString() == "int") { #>
157+
$this->propDict["<#=property.Name#>"] = intval($val);
158+
<# } else { #>
159+
$this->propDict["<#=property.Name#>"] = $val;
160+
<# } #>
149161
<#
150162
}
151163
#>

0 commit comments

Comments
 (0)