1 | <?php |
||
18 | class SchemaModel implements ContainerAwareInterface |
||
19 | { |
||
20 | /** |
||
21 | * object |
||
22 | */ |
||
23 | private $schema; |
||
24 | |||
25 | /** |
||
26 | * @var ContainerInterface |
||
27 | */ |
||
28 | private $container; |
||
29 | |||
30 | /** |
||
31 | * load some schema info for the model |
||
32 | */ |
||
33 | 4 | public function __construct() |
|
61 | |||
62 | /** |
||
63 | * inject container |
||
64 | * |
||
65 | * @param ContainerInterface $container service container |
||
|
|||
66 | * |
||
67 | * @return self |
||
68 | */ |
||
69 | 4 | public function setContainer(ContainerInterface $container = null) |
|
75 | |||
76 | /** |
||
77 | * get Title |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getTitle() |
||
85 | |||
86 | /** |
||
87 | * get description |
||
88 | * |
||
89 | * @return string Description |
||
90 | */ |
||
91 | public function getDescription() |
||
95 | |||
96 | /** |
||
97 | * get recordOriginModifiable |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | public function getRecordOriginModifiable() |
||
108 | |||
109 | /** |
||
110 | * Returns the bare schema |
||
111 | * |
||
112 | * @return \stdClass Schema |
||
113 | */ |
||
114 | public function getSchema() |
||
118 | |||
119 | /** |
||
120 | * get title for a given field |
||
121 | * |
||
122 | * @param string $field field name |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getTitleOfField($field) |
||
130 | |||
131 | /** |
||
132 | * get description for a given field |
||
133 | * |
||
134 | * @param string $field field name |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getDescriptionOfField($field) |
||
142 | |||
143 | /** |
||
144 | * get property model for embedded field |
||
145 | * |
||
146 | * @param string $mapping name of mapping class |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function manyPropertyModelForTarget($mapping) |
||
162 | |||
163 | /** |
||
164 | * get required fields for this object |
||
165 | * |
||
166 | * @return string[] |
||
167 | */ |
||
168 | public function getRequiredFields() |
||
172 | |||
173 | /** |
||
174 | * get a collection of service names that can extref refer to |
||
175 | * |
||
176 | * @param string $field field name |
||
177 | * |
||
178 | * @return array |
||
179 | */ |
||
180 | public function getRefCollectionOfField($field) |
||
184 | |||
185 | /** |
||
186 | * get readOnly flag for a given field |
||
187 | * |
||
188 | * @param string $field field name |
||
189 | * |
||
190 | * @return boolean the readOnly flag |
||
191 | */ |
||
192 | public function getReadOnlyOfField($field) |
||
196 | |||
197 | /** |
||
198 | * get readOnly flag for a given field |
||
199 | * |
||
200 | * @param string $field field name |
||
201 | * |
||
202 | * @return boolean the readOnly flag |
||
203 | */ |
||
204 | public function getRecordOriginExceptionOfField($field) |
||
208 | |||
209 | /** |
||
210 | * get searchable flag for a given field, weight based. |
||
211 | * |
||
212 | * @param string $field field name |
||
213 | * |
||
214 | * @return integer the searchable flag |
||
215 | */ |
||
216 | public function getSearchableOfField($field) |
||
220 | |||
221 | /** |
||
222 | * tell us if a model what to be exposed using a key as field |
||
223 | * |
||
224 | * @param string $field field that we check for dynamic-key spec |
||
225 | * |
||
226 | * @return boolean |
||
227 | */ |
||
228 | public function hasDynamicKey($field) |
||
232 | |||
233 | /** |
||
234 | * Get field used for setting stringy key value |
||
235 | * |
||
236 | * @param string $field field that we get dynamic-key spec from |
||
237 | * |
||
238 | * @return object |
||
239 | */ |
||
240 | public function getDynamicKeySpec($field) |
||
244 | |||
245 | /** |
||
246 | * Gets the defined document class in shortform from schema |
||
247 | * |
||
248 | * @return string|false either the document class or false it not given |
||
249 | */ |
||
250 | public function getDocumentClass() |
||
258 | |||
259 | /** |
||
260 | * Get defined constraints on this field (if any) |
||
261 | * |
||
262 | * @param string $field field that we get constraints spec from |
||
263 | * |
||
264 | * @return object |
||
265 | */ |
||
266 | public function getConstraints($field) |
||
270 | |||
271 | /** |
||
272 | * Tells us if in this model, the ID can be given on a POST request or not (in the payload). |
||
273 | * This basically depends on if the "id" property is given in the JSON definition or not. |
||
274 | * |
||
275 | * @return bool true if yes, false otherwise |
||
276 | */ |
||
277 | public function isIdInPostAllowed() |
||
285 | |||
286 | /** |
||
287 | * get schema field value |
||
288 | * |
||
289 | * @param string $field field name |
||
290 | * @param string $property property name |
||
291 | * @param mixed $fallbackValue fallback value if property isn't set |
||
292 | * |
||
293 | * @return mixed |
||
294 | */ |
||
295 | private function getSchemaField($field, $property, $fallbackValue = '') |
||
303 | |||
304 | /** |
||
305 | * get searchable fields for this object |
||
306 | * |
||
307 | * @return string[] |
||
308 | */ |
||
309 | public function getSearchableFields() |
||
313 | } |
||
314 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.