1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Part of JSON definition |
4
|
|
|
*/ |
5
|
|
|
namespace Graviton\GeneratorBundle\Definition\Schema; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* JSON definition "target.fields" |
9
|
|
|
* |
10
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
11
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
12
|
|
|
* @link http://swisscom.ch |
13
|
|
|
*/ |
14
|
|
|
class Field |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $name; |
20
|
|
|
/** |
21
|
|
|
* @var array |
22
|
|
|
*/ |
23
|
|
|
private $groups; |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $type; |
28
|
|
|
/** |
29
|
|
|
* @var int |
30
|
|
|
*/ |
31
|
|
|
private $length; |
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $title; |
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $description; |
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $exposeAs; |
44
|
|
|
/** |
45
|
|
|
* @var bool |
46
|
|
|
*/ |
47
|
|
|
private $readOnly = false; |
48
|
|
|
/** |
49
|
|
|
* @var bool |
50
|
|
|
*/ |
51
|
|
|
private $recordOriginException = false; |
52
|
|
|
/** |
53
|
|
|
* @var bool |
54
|
|
|
*/ |
55
|
|
|
private $required = false; |
56
|
|
|
/** |
57
|
|
|
* @var integer |
58
|
|
|
*/ |
59
|
|
|
private $searchable = 0; |
60
|
|
|
/** |
61
|
|
|
* @var bool |
62
|
|
|
*/ |
63
|
|
|
private $translatable = false; |
64
|
|
|
/** |
65
|
|
|
* @var Constraint[] |
66
|
|
|
*/ |
67
|
|
|
private $constraints = []; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var array |
71
|
|
|
*/ |
72
|
|
|
private $collection = []; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var XDynamicKey |
76
|
|
|
*/ |
77
|
|
|
private $xDynamicKey; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
30 |
|
public function getName() |
83
|
|
|
{ |
84
|
30 |
|
return $this->name; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param string $name Field name |
89
|
|
|
* @return $this |
90
|
|
|
*/ |
91
|
16 |
|
public function setName($name) |
92
|
|
|
{ |
93
|
16 |
|
$this->name = $name; |
94
|
16 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* get Groups |
99
|
|
|
* |
100
|
|
|
* @return array Groups |
101
|
|
|
*/ |
102
|
16 |
|
public function getGroups() |
103
|
|
|
{ |
104
|
16 |
|
return $this->groups; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* set Groups |
109
|
|
|
* |
110
|
|
|
* @param array $groups groups |
111
|
|
|
* |
112
|
|
|
* @return void |
|
|
|
|
113
|
|
|
*/ |
114
|
4 |
|
public function setGroups($groups) |
115
|
|
|
{ |
116
|
4 |
|
$this->groups = $groups; |
117
|
4 |
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
80 |
|
public function getType() |
124
|
|
|
{ |
125
|
80 |
|
return $this->type; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $type Field type |
130
|
|
|
* @return $this |
131
|
|
|
*/ |
132
|
58 |
|
public function setType($type) |
133
|
|
|
{ |
134
|
58 |
|
$this->type = $type; |
135
|
58 |
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return int |
140
|
|
|
*/ |
141
|
16 |
|
public function getLength() |
142
|
|
|
{ |
143
|
16 |
|
return $this->length; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @param int $length Field length |
148
|
|
|
* @return $this |
149
|
|
|
*/ |
150
|
4 |
|
public function setLength($length) |
151
|
|
|
{ |
152
|
4 |
|
$this->length = $length; |
153
|
4 |
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
22 |
|
public function getTitle() |
160
|
|
|
{ |
161
|
22 |
|
return $this->title; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param string $title Field title |
166
|
|
|
* @return $this |
167
|
|
|
*/ |
168
|
6 |
|
public function setTitle($title) |
169
|
|
|
{ |
170
|
6 |
|
$this->title = $title; |
171
|
6 |
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return string |
176
|
|
|
*/ |
177
|
22 |
|
public function getDescription() |
178
|
|
|
{ |
179
|
22 |
|
return $this->description; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param string $description Field description |
184
|
|
|
* @return $this |
185
|
|
|
*/ |
186
|
12 |
|
public function setDescription($description) |
187
|
|
|
{ |
188
|
12 |
|
$this->description = $description; |
189
|
12 |
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return string |
194
|
|
|
*/ |
195
|
18 |
|
public function getExposeAs() |
196
|
|
|
{ |
197
|
18 |
|
return $this->exposeAs; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @param string $exposeAs Expose field as ... |
202
|
|
|
* @return $this |
203
|
|
|
*/ |
204
|
10 |
|
public function setExposeAs($exposeAs) |
205
|
|
|
{ |
206
|
10 |
|
$this->exposeAs = $exposeAs; |
207
|
10 |
|
return $this; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @return bool |
212
|
|
|
*/ |
213
|
18 |
|
public function getReadOnly() |
214
|
|
|
{ |
215
|
18 |
|
return $this->readOnly; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @param bool $readOnly Is field readonly |
220
|
|
|
* @return $this |
221
|
|
|
*/ |
222
|
6 |
|
public function setReadOnly($readOnly) |
223
|
|
|
{ |
224
|
6 |
|
$this->readOnly = $readOnly; |
225
|
6 |
|
return $this; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* get RecordOriginException |
230
|
|
|
* |
231
|
|
|
* @return boolean RecordOriginException |
232
|
|
|
*/ |
233
|
16 |
|
public function isRecordOriginException() |
234
|
|
|
{ |
235
|
16 |
|
return $this->recordOriginException; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* set RecordOriginException |
240
|
|
|
* |
241
|
|
|
* @param boolean $recordOriginException recordOriginException |
242
|
|
|
* |
243
|
|
|
* @return void |
244
|
|
|
*/ |
245
|
|
|
public function setRecordOriginException($recordOriginException) |
246
|
|
|
{ |
247
|
|
|
$this->recordOriginException = $recordOriginException; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @return bool |
252
|
|
|
*/ |
253
|
20 |
|
public function getRequired() |
254
|
|
|
{ |
255
|
20 |
|
return $this->required; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* @param bool $required Is field required |
260
|
|
|
* @return $this |
261
|
|
|
*/ |
262
|
10 |
|
public function setRequired($required) |
263
|
|
|
{ |
264
|
10 |
|
$this->required = $required; |
265
|
10 |
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return bool |
270
|
|
|
*/ |
271
|
16 |
|
public function getTranslatable() |
272
|
|
|
{ |
273
|
16 |
|
return $this->translatable; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param bool $translatable Is field translatable |
278
|
|
|
* @return $this |
279
|
|
|
*/ |
280
|
4 |
|
public function setTranslatable($translatable) |
281
|
|
|
{ |
282
|
4 |
|
$this->translatable = $translatable; |
283
|
4 |
|
return $this; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @return Constraint[] |
288
|
|
|
*/ |
289
|
18 |
|
public function getConstraints() |
290
|
|
|
{ |
291
|
18 |
|
return $this->constraints; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @param Constraint[] $constraints Field constraints |
296
|
|
|
* @return $this |
297
|
|
|
*/ |
298
|
4 |
|
public function setConstraints(array $constraints) |
299
|
|
|
{ |
300
|
4 |
|
$this->constraints = $constraints; |
301
|
4 |
|
return $this; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* @return array |
306
|
|
|
*/ |
307
|
16 |
|
public function getCollection() |
308
|
|
|
{ |
309
|
16 |
|
return $this->collection; |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* @param array $collection Field |
314
|
|
|
* @return $this |
315
|
|
|
*/ |
316
|
4 |
|
public function setCollection(array $collection) |
317
|
|
|
{ |
318
|
4 |
|
$this->collection = $collection; |
319
|
4 |
|
return $this; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* @return XDynamicKey |
324
|
|
|
*/ |
325
|
18 |
|
public function getXDynamicKey() |
326
|
|
|
{ |
327
|
18 |
|
return $this->xDynamicKey; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* @param XDynamicKey $xDynamicKey x-dynamic-key field value |
332
|
|
|
* @return $this |
333
|
|
|
*/ |
334
|
2 |
|
public function setXDynamicKey(XDynamicKey $xDynamicKey) |
335
|
|
|
{ |
336
|
2 |
|
$this->xDynamicKey = $xDynamicKey; |
337
|
2 |
|
return $this; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* @return integer |
342
|
|
|
*/ |
343
|
18 |
|
public function getSearchable() |
344
|
|
|
{ |
345
|
18 |
|
return (int) $this->searchable; |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
/** |
349
|
|
|
* @param integer $searchable searchable flag |
350
|
|
|
* |
351
|
|
|
* @return void |
352
|
|
|
*/ |
353
|
|
|
public function setSearchable($searchable) |
354
|
|
|
{ |
355
|
|
|
$this->searchable = (int) $searchable; |
356
|
|
|
} |
357
|
|
|
} |
358
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.