Skip to content

Commit 476dce5

Browse files
author
Caitlin Bales (MSFT)
committed
Update base entity model to imlement json serialization
1 parent 6342d1f commit 476dce5

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Templates/PHP/Model/EntityType.php.tt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ 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
#>
@@ -65,11 +65,11 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
6565
if (property.IsCollection()) {
6666
#>
6767

68-
/**
69-
* Gets the <#=property.Name#>
70-
*
71-
* @return array The <#=property.Name#>
72-
*/
68+
/**
69+
* Gets the <#=property.Name#>
70+
*
71+
* @return array The <#=property.Name#>
72+
*/
7373
public function get<#=property.Name.ToCheckedCase()#>()
7474
{
7575
if (array_key_exists("<#=property.Name.ToCamelize()#>", $this->_propDict)) {
@@ -193,5 +193,18 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
193193
<#
194194
}
195195
}
196+
if (entity.Name.ToCheckedCase() == "Entity") {
197+
#>
198+
/**
199+
* Serializes the object by property array
200+
*
201+
* @return array The list of properties
202+
*/
203+
public function jsonSerialize()
204+
{
205+
return $this->getProperties();
206+
}
207+
<#
208+
}
196209
#>
197210
}

0 commit comments

Comments
 (0)