Skip to content

Commit 0724fa8

Browse files
author
Caitlin Bales (MSFT)
committed
Add collection return type (arrays)
1 parent ae2ac3c commit 0724fa8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Templates/PHP/Model/EntityType.php.tt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,27 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
6363
/**
6464
* Gets the <#=property.Name#>
6565
*
66-
* @return <#=propertyNameCap#>CollectionPage The <#=property.Name#>
66+
* @return array(<#=property.Name.ToCheckedCase().Remove(property.Name.ToCheckedCase().Length - 1)#>) The <#=property.Name#>
6767
*/
6868
public function get<#=property.Name.ToCheckedCase()#>()
6969
{
7070
if (array_key_exists("<#=property.Name.ToCamelize()#>", $this->_propDict)) {
71-
return <#=propertyNameCap#>CollectionPage($this->_propDict["<#=property.Name.ToCamelize()#>"]);
71+
if (array_key_exists(0, $this->_propDict["<#=property.Name.ToCamelize()#>"]) &&
72+
is_a($this->_propDict["<#=property.Name.ToCamelize()#>"][0], 'Microsoft\\Graph\\Model\\<#=property.Name.ToCheckedCase().Remove(property.Name.ToCheckedCase().Length - 1)#>')) {
73+
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
74+
} else {
75+
$collection = array();
76+
foreach ($this->_propDict["<#=property.Name.ToCamelize()#>"] as $item)
77+
{
78+
$collection[] = new <#=property.Name.ToCheckedCase().Remove(property.Name.ToCheckedCase().Length - 1)#>($item);
79+
}
80+
$this->_propDict["<#=property.Name.ToCamelize()#>"] = $collection;
81+
return $this->_propDict["<#=property.Name.ToCamelize()#>"];
82+
}
7283
} else {
7384
return null;
7485
}
7586
}
76-
7787

7888
/**
7989
* Sets the <#=property.Name#>

0 commit comments

Comments
 (0)