1+ <# // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. #>
2+ <#@ template debug="true" hostspecific="true" language="C#" #>
3+ <#@ output extension="\\" #>
4+ <#
5+ CustomT4Host host = (CustomT4Host) Host;
6+ OdcmModel model = host.CurrentModel;
7+ CodeWriterPHP writer = (CodeWriterPHP) host.CodeWriter;
8+ OdcmClass entity = host.CurrentType.AsOdcmClass();
9+ TemplateWriterSettings settings = ConfigurationService.Settings;
10+
11+ #>
12+ <#=writer.WriteHeader(writer.GetDocBlock(entity.Name.ToCheckedCase()))#>
13+ namespace Microsoft\Graph\Model;
14+
15+ <#=writer.GetClassBlock(entity.Name.ToCheckedCase().ToString(), "Model")#>
16+ <#
17+ if (entity.Name.ToCheckedCase() == "Entity") {
18+ #>
19+ class <#=entity.Name.ToCheckedCase()#>
20+ <#
21+ } else {
22+ #>
23+ class <#=entity.Name.ToCheckedCase()#> extends Entity
24+ <#
25+ }
26+ #>
27+ {
28+ /**
29+ * The array of properties available
30+ * to the model
31+ *
32+ * @var array(string => string)
33+ */
34+ private $_propDict;
35+
36+ /**
37+ * Construct a new <#=entity.Name.ToCheckedCase()#>
38+ *
39+ * @param array $propDict A list of properties to set
40+ *
41+ * @return <#=entity.Name.ToCheckedCase()#>
42+ */
43+ function __construct($propDict = array())
44+ {
45+ <#
46+ if (!(entity.Name.ToCheckedCase() == "Entity")) {
47+ #>
48+ parent::__construct();
49+ <#
50+ }
51+ #>
52+ $this->_propDict = $propDict;
53+ return $this;
54+ }
55+
56+ /**
57+ * Gets the property dictionary of the <#=entity.Name.ToUpperFirstChar()#>
58+ *
59+ * @return array The list of properties
60+ */
61+ public function getProperties()
62+ {
63+ return $this->_propDict;
64+ }
65+ <#
66+ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString() != "bytes")){
67+ var propertyName = property.Name.ToUnderscore();
68+ var propertyNameCap = property.Name.ToUpperFirstChar();
69+ if (property.Type.IsComplex()) {
70+ if (property.IsCollection()) {
71+ #>
72+
73+ /**
74+ * Gets the <#=property.Name#>
75+ *
76+ * @return array The <#=property.Name#>
77+ */
78+ public function get<#=property.Name.ToCheckedCase()#>()
79+ {
80+ if (array_key_exists("<#=property.Name.ToCamelize()#>", $this->_propDict)) {
81+ return $this->_propDict["<#=property.Name.ToCamelize()#>"];
82+ } else {
83+ return null;
84+ }
85+ }
86+
87+ /**
88+ * Sets the <#=property.Name#>
89+ *
90+ * @param string $val The <#=property.Name#>
91+ *
92+ * @return <#=entity.Name.ToCheckedCase()#>
93+ */
94+ public function set<#=property.Name.ToCheckedCase()#>($val)
95+ {
96+ $this->_propDict["<#=property.Name.ToCamelize()#>"] = $val;
97+ return $this;
98+ }
99+
100+ <#
101+ } else {
102+ #>
103+
104+ /**
105+ * Gets the <#=property.Name#>
106+ *
107+ * @return <#=property.Type.GetTypeString()#> The <#=property.Name#>
108+ */
109+ public function get<#=property.Name.ToCheckedCase()#>()
110+ {
111+ if (array_key_exists("<#=property.Name.ToCamelize()#>", $this->_propDict)) {
112+ if (is_a($this->_propDict["<#=property.Name.ToCamelize()#>"], "<#=property.Type.GetTypeString()#>")) {
113+ return $this->_propDict["<#=property.Name.ToCamelize()#>"];
114+ } else {
115+ $this->_propDict["<#=property.Name.ToCamelize()#>"] = new <#=property.Type.GetTypeString()#>($this->_propDict["<#=property.Name.ToCamelize()#>"]);
116+ return $this->_propDict["<#=property.Name.ToCamelize()#>"];
117+ }
118+ }
119+ return null;
120+ }
121+
122+ /**
123+ * Sets the <#=property.Name#>
124+ *
125+ * @param string $val The <#=property.Name#>
126+ *
127+ * @return <#=entity.Name.ToCheckedCase()#>
128+ */
129+ public function set<#=property.Name.ToCheckedCase()#>($val)
130+ {
131+ <# if (property.Type.GetTypeString() == "bool") { #>
132+ $this->_propDict["<#=property.Name#>"] = boolval($val);
133+ <# } else if (property.Type.GetTypeString() == "int") { #>
134+ $this->_propDict["<#=property.Name#>"] = intval($val);
135+ <# } else { #>
136+ $this->_propDict["<#=property.Name#>"] = $val;
137+ <# } #>
138+ return $this;
139+ }
140+ <#
141+ }
142+ } else {
143+ #>
144+
145+ /**
146+ * Gets the <#=property.Name#>
147+ *
148+ * @return <#=property.Type.GetTypeString()#> The <#=property.Name#>
149+ */
150+ public function get<#=property.Name.ToCheckedCase()#>()
151+ {
152+ if (array_key_exists("<#=property.Name.ToCamelize()#>", $this->_propDict)) {
153+ <#
154+ if (property.Type.GetTypeString() == "\\DateTime") {
155+ #>
156+ return new \DateTime($this->_propDict["<#=property.Name.ToCamelize()#>"]);
157+ <#
158+ } else {
159+ #>
160+ return $this->_propDict["<#=property.Name.ToCamelize()#>"];
161+ <#
162+ }
163+ #>
164+ } else {
165+ return null;
166+ }
167+ }
168+
169+ /**
170+ * Sets the <#=property.Name#>
171+ *
172+ * @param <#=property.Type.GetTypeString()#> $val The <#=property.Name#>
173+ *
174+ * @return <#=entity.Name.ToCheckedCase()#>
175+ */
176+ public function set<#=property.Name.ToCheckedCase()#>($val)
177+ {
178+ <#
179+ if (property.Type.GetTypeString() == "\\DateTime") {
180+ #>
181+ $this->_propDict["<#=property.Name.ToCamelize()#>"]
182+ = $val->format(\DateTime::ISO8601) . "Z";
183+ <#
184+ } else {
185+ #>
186+ <# if (property.Type.GetTypeString() == "bool") { #>
187+ $this->_propDict["<#=property.Name#>"] = boolval($val);
188+ <# } else if (property.Type.GetTypeString() == "int") { #>
189+ $this->_propDict["<#=property.Name#>"] = intval($val);
190+ <# } else { #>
191+ $this->_propDict["<#=property.Name#>"] = $val;
192+ <# } #>
193+ <#
194+ }
195+ #>
196+ return $this;
197+ }
198+ <#
199+ }
200+ }
201+ #>
202+ }
0 commit comments