Skip to content

Commit c7acf46

Browse files
author
Caitlin Bales (MSFT)
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into cbales-working
# Conflicts: # Templates/PHP/Model/EntityType.php.tt
2 parents ba9c0a5 + 9537e7e commit c7acf46

File tree

2 files changed

+67
-22
lines changed

2 files changed

+67
-22
lines changed

Templates/PHP/Model/ComplexType.php.tt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ OdcmClass complex = (OdcmClass)host.CurrentType;
1010
<#=writer.WriteHeader(writer.GetDocBlock(complex.Name.ToCheckedCase()))#>
1111
namespace Microsoft\Graph\Model;
1212
<#=writer.GetClassBlock(complex.Name.ToCheckedCase().ToString(), "Model")#>
13+
<#
14+
if (complex.Base != null) {
15+
#>
16+
class <#=complex.Name.ToCheckedCase()#> extends <#=complex.Base.Name.ToCheckedCase()#>
17+
<#
18+
} else {
19+
#>
1320
class <#=complex.Name.ToCheckedCase()#> extends Entity
21+
<#
22+
}
23+
#>
1424
{
15-
/**
16-
* Gets the property dictionary of the <#=complex.Name.ToCheckedCase()#>
17-
*
18-
* @return array The list of properties
19-
*/
20-
public function getProperties()
21-
{
22-
return $this->_propDict;
23-
}
2425
<#
2526
foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
2627
var propertyName = property.Name.ToUnderscore();
2728
if (!property.Type.IsComplex()) {
2829
#>
29-
3030
/**
3131
* Gets the <#=property.Name#>
3232
<# if (property.LongDescription != null) {
@@ -101,8 +101,13 @@ foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString
101101
if (is_a($this->_propDict["<#=property.Name.ToCamelize()#>"], "<#=property.Type.GetTypeString()#>")) {
102102
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
103103
} else {
104+
<# if (property.Type.GetTypeString() == "\\GuzzleHttp\\Psr7\\Stream") { #>
105+
$this->_propDict["<#=property.Name.ToCamelize()#>"] = \GuzzleHttp\Psr7\stream_for($this->_propDict["<#=property.Name.ToCamelize()#>"]);
106+
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
107+
<# } else { #>
104108
$this->_propDict["<#=property.Name.ToCamelize()#>"] = new <#=property.Type.GetTypeString()#>($this->_propDict["<#=property.Name.ToCamelize()#>"]);
105109
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
110+
<# } #>
106111
}
107112
}
108113
return null;

Templates/PHP/Model/EntityType.php.tt

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ namespace Microsoft\Graph\Model;
1616
<#
1717
if (entity.Name.ToCheckedCase() == "Entity") {
1818
#>
19-
class <#=entity.Name.ToCheckedCase()#>
19+
class <#=entity.Name.ToCheckedCase()#> implements \JsonSerializable
2020
<#
2121
} else {
2222
#>
23-
class <#=entity.Name.ToCheckedCase()#> extends Entity
23+
class <#=entity.Name.ToCheckedCase()#> extends <#=entity.Base.Name.ToCheckedCase() #>
2424
<#
2525
}
2626
#>
@@ -45,9 +45,7 @@ if (entity.Name.ToCheckedCase() == "Entity") {
4545
{
4646
$this->_propDict = $propDict;
4747
}
48-
<#
49-
}
50-
#>
48+
5149
/**
5250
* Gets the property dictionary of the <#=entity.Name.ToUpperFirstChar()#>
5351
*
@@ -57,7 +55,9 @@ if (entity.Name.ToCheckedCase() == "Entity") {
5755
{
5856
return $this->_propDict;
5957
}
60-
<#
58+
59+
<#
60+
}
6161
foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
6262
var propertyName = property.Name.ToUnderscore();
6363
var propertyNameCap = property.Name.ToUpperFirstChar();
@@ -82,7 +82,7 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
8282
return null;
8383
}
8484
}
85-
85+
8686
/**
8787
* Sets the <#=property.Name#>
8888
<# if (property.LongDescription != null) {
@@ -99,11 +99,10 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
9999
$this->_propDict["<#=property.Name.ToCamelize()#>"] = $val;
100100
return $this;
101101
}
102-
102+
103103
<#
104104
} else {
105105
#>
106-
107106
/**
108107
* Gets the <#=property.Name#>
109108
<# if (property.LongDescription != null) {
@@ -119,13 +118,18 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
119118
if (is_a($this->_propDict["<#=property.Name.ToCamelize()#>"], "<#=property.Type.GetTypeString()#>")) {
120119
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
121120
} else {
121+
<# if (property.Type.GetTypeString() == "\\GuzzleHttp\\Psr7\\Stream") { #>
122+
$this->_propDict["<#=property.Name.ToCamelize()#>"] = \GuzzleHttp\Psr7\stream_for($this->_propDict["<#=property.Name.ToCamelize()#>"]);
123+
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
124+
<# } else { #>
122125
$this->_propDict["<#=property.Name.ToCamelize()#>"] = new <#=property.Type.GetTypeString()#>($this->_propDict["<#=property.Name.ToCamelize()#>"]);
123126
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
127+
<# } #>
124128
}
125129
}
126130
return null;
127131
}
128-
132+
129133
/**
130134
* Sets the <#=property.Name#>
131135
<# if (property.LongDescription != null) {
@@ -148,11 +152,11 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
148152
<# } #>
149153
return $this;
150154
}
155+
151156
<#
152157
}
153158
} else {
154159
#>
155-
156160
/**
157161
* Gets the <#=property.Name#>
158162
<# if (property.LongDescription != null) {
@@ -180,7 +184,7 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
180184
return null;
181185
}
182186
}
183-
187+
184188
/**
185189
* Sets the <#=property.Name#>
186190
<# if (property.LongDescription != null) {
@@ -214,8 +218,44 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
214218
#>
215219
return $this;
216220
}
221+
217222
<#
218223
}
219224
}
225+
if (entity.Name.ToCheckedCase() == "Entity") {
226+
#>
227+
/**
228+
* Gets the ODataType
229+
*
230+
* @return string The ODataType
231+
*/
232+
public function getODataType()
233+
{
234+
return $this->_propDict["@odata.type"];
235+
}
236+
237+
/**
238+
* Sets the ODataType
239+
*
240+
* @param string The ODataType
241+
*
242+
* @return Entity
243+
*/
244+
public function setODataType($val)
245+
{
246+
$this->_propDict["@odata.type"] = $val;
247+
}
248+
249+
/**
250+
* Serializes the object by property array
251+
*
252+
* @return array The list of properties
253+
*/
254+
public function jsonSerialize()
255+
{
256+
return $this->getProperties();
257+
}
258+
<#
259+
}
220260
#>
221261
}

0 commit comments

Comments
 (0)