Skip to content

Commit 3a61632

Browse files
author
Caitlin Bales (MSFT)
committed
Add collection setters
1 parent 087934d commit 3a61632

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

Templates/PHP/Model/ComplexType.php.tt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class <#=complex.Name.ToUpperFirstChar()#>
3232
$this->_propDict = $propDict;
3333
}
3434
<#
35-
foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
36-
var propertyName = property.Name.ToUnderscore();
37-
if (!property.Type.IsComplex()) {
35+
foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
36+
var propertyName = property.Name.ToUnderscore();
37+
if (!property.Type.IsComplex()) {
3838
#>
3939

4040
/**
@@ -85,7 +85,7 @@ class <#=complex.Name.ToUpperFirstChar()#>
8585
return $this;
8686
}
8787
<#
88-
} else {
88+
} else {
8989
#>
9090

9191
/**

Templates/PHP/Model/EntityType.php.tt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class <#=entity.Name.ToCheckedCase()#>
2222
* @var array(string => string)
2323
*/
2424
private $_propDict;
25+
2526
/**
2627
* Construct a new <#=entity.Name.ToUpperFirstChar()#>
2728
*
@@ -42,11 +43,11 @@ class <#=entity.Name.ToCheckedCase()#>
4243
return $this->_propDict;
4344
}
4445
<#
45-
foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
46-
var propertyName = property.Name.ToUnderscore();
47-
var propertyNameCap = property.Name.ToUpperFirstChar();
48-
if (property.Type.IsComplex()) {
49-
if (property.IsCollection()) {
46+
foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
47+
var propertyName = property.Name.ToUnderscore();
48+
var propertyNameCap = property.Name.ToUpperFirstChar();
49+
if (property.Type.IsComplex()) {
50+
if (property.IsCollection()) {
5051
#>
5152

5253
/**
@@ -63,8 +64,22 @@ class <#=entity.Name.ToCheckedCase()#>
6364
}
6465
}
6566

67+
68+
/**
69+
* Sets the <#=property.Name#>
70+
*
71+
* @param string $val The <#=property.Name#>
72+
*
73+
* @return <#=entity.Name.ToCheckedCase()#>
74+
*/
75+
public function set<#=property.Name.ToCheckedCase()#>($val)
76+
{
77+
$this->_propDict["<#=property.Name.ToCamelize()#>"] = $val;
78+
return $this;
79+
}
80+
6681
<#
67-
} else {
82+
} else {
6883
#>
6984

7085
/**

0 commit comments

Comments
 (0)