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 | public function __construct() |
||
56 | |||
57 | /** |
||
58 | * inject container |
||
59 | * |
||
60 | * @param ContainerInterface $container service container |
||
|
|||
61 | * |
||
62 | * @return self |
||
63 | */ |
||
64 | public function setContainer(ContainerInterface $container = null) |
||
70 | |||
71 | /** |
||
72 | * get Title |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function getTitle() |
||
80 | |||
81 | /** |
||
82 | * get description |
||
83 | * |
||
84 | * @return string Description |
||
85 | */ |
||
86 | public function getDescription() |
||
90 | |||
91 | /** |
||
92 | * get recordOriginModifiable |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function getRecordOriginModifiable() |
||
97 | { |
||
98 | if (isset($this->schema->recordOriginModifiable)) { |
||
99 | return $this->schema->recordOriginModifiable; |
||
100 | } |
||
101 | return true; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Returns the bare schema |
||
106 | * |
||
107 | * @return \stdClass Schema |
||
108 | */ |
||
109 | public function getSchema() |
||
113 | |||
114 | /** |
||
115 | * get title for a given field |
||
116 | * |
||
117 | * @param string $field field name |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getTitleOfField($field) |
||
125 | |||
126 | /** |
||
127 | * get description for a given field |
||
128 | * |
||
129 | * @param string $field field name |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | public function getDescriptionOfField($field) |
||
137 | |||
138 | /** |
||
139 | * get property model for embedded field |
||
140 | * |
||
141 | * @param string $mapping name of mapping class |
||
142 | * |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function manyPropertyModelForTarget($mapping) |
||
157 | |||
158 | /** |
||
159 | * get required fields for this object |
||
160 | * |
||
161 | * @return string[] |
||
162 | */ |
||
163 | public function getRequiredFields() |
||
167 | |||
168 | /** |
||
169 | * get a collection of service names that can extref refer to |
||
170 | * |
||
171 | * @param string $field field name |
||
172 | * |
||
173 | * @return array |
||
174 | */ |
||
175 | public function getRefCollectionOfField($field) |
||
179 | |||
180 | /** |
||
181 | * get readOnly flag for a given field |
||
182 | * |
||
183 | * @param string $field field name |
||
184 | * |
||
185 | * @return boolean the readOnly flag |
||
186 | */ |
||
187 | public function getReadOnlyOfField($field) |
||
191 | |||
192 | /** |
||
193 | * get hideOnEmptyExtref flag for a given field |
||
194 | * |
||
195 | * @param string $field field name |
||
196 | * |
||
197 | * @return boolean the hideOnEmptyExtref flag |
||
198 | */ |
||
199 | public function getHideOnEmptyExtref($field) |
||
203 | |||
204 | /** |
||
205 | * get readOnly flag for a given field |
||
206 | * |
||
207 | * @param string $field field name |
||
208 | * |
||
209 | * @return boolean the readOnly flag |
||
210 | */ |
||
211 | public function getRecordOriginExceptionOfField($field) |
||
215 | |||
216 | /** |
||
217 | * get searchable flag for a given field, weight based. |
||
218 | * |
||
219 | * @param string $field field name |
||
220 | * |
||
221 | * @return integer the searchable flag |
||
222 | */ |
||
223 | public function getSearchableOfField($field) |
||
227 | |||
228 | /** |
||
229 | * tell us if a model what to be exposed using a key as field |
||
230 | * |
||
231 | * @param string $field field that we check for dynamic-key spec |
||
232 | * |
||
233 | * @return boolean |
||
234 | */ |
||
235 | public function hasDynamicKey($field) |
||
239 | |||
240 | /** |
||
241 | * Get field used for setting stringy key value |
||
242 | * |
||
243 | * @param string $field field that we get dynamic-key spec from |
||
244 | * |
||
245 | * @return object |
||
246 | */ |
||
247 | public function getDynamicKeySpec($field) |
||
251 | |||
252 | /** |
||
253 | * Gets the defined document class in shortform from schema |
||
254 | * |
||
255 | * @return string|false either the document class or false it not given |
||
256 | */ |
||
257 | public function getDocumentClass() |
||
265 | |||
266 | /** |
||
267 | * Get defined constraints on this field (if any) |
||
268 | * |
||
269 | * @param string $field field that we get constraints spec from |
||
270 | * |
||
271 | * @return object |
||
272 | */ |
||
273 | public function getConstraints($field) |
||
277 | |||
278 | /** |
||
279 | * Tells us if in this model, the ID can be given on a POST request or not (in the payload). |
||
280 | * This basically depends on if the "id" property is given in the JSON definition or not. |
||
281 | * |
||
282 | * @return bool true if yes, false otherwise |
||
283 | */ |
||
284 | public function isIdInPostAllowed() |
||
292 | |||
293 | /** |
||
294 | * get schema field value |
||
295 | * |
||
296 | * @param string $field field name |
||
297 | * @param string $property property name |
||
298 | * @param mixed $fallbackValue fallback value if property isn't set |
||
299 | * |
||
300 | * @return mixed |
||
301 | */ |
||
302 | private function getSchemaField($field, $property, $fallbackValue = '') |
||
310 | |||
311 | /** |
||
312 | * get searchable fields for this object |
||
313 | * |
||
314 | * @return string[] |
||
315 | */ |
||
316 | public function getSearchableFields() |
||
320 | } |
||
321 |
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.