1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Part of JSON definition |
4
|
|
|
*/ |
5
|
|
|
namespace Graviton\GeneratorBundle\Definition\Schema; |
6
|
|
|
|
7
|
|
|
use Graviton\GeneratorBundle\Definition\Schema\XDynamicKey; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* JSON definition "target.fields" |
11
|
|
|
* |
12
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
13
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
14
|
|
|
* @link http://swisscom.ch |
15
|
|
|
*/ |
16
|
|
|
class Field |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $name; |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
private $type; |
26
|
|
|
/** |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
private $length; |
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $title; |
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
private $description; |
38
|
|
|
/** |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $exposeAs; |
42
|
|
|
/** |
43
|
|
|
* @var bool |
44
|
|
|
*/ |
45
|
|
|
private $readOnly = false; |
46
|
|
|
/** |
47
|
|
|
* @var bool |
48
|
|
|
*/ |
49
|
|
|
private $required = false; |
50
|
|
|
/** |
51
|
|
|
* @var bool |
52
|
|
|
*/ |
53
|
|
|
private $searchable = false; |
54
|
|
|
/** |
55
|
|
|
* @var bool |
56
|
|
|
*/ |
57
|
|
|
private $translatable = false; |
58
|
|
|
/** |
59
|
|
|
* @var Constraint[] |
60
|
|
|
*/ |
61
|
|
|
private $constraints = []; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var array |
65
|
|
|
*/ |
66
|
|
|
private $collection = []; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var XDynamicKey |
70
|
|
|
*/ |
71
|
|
|
private $xDynamicKey; |
72
|
15 |
|
|
73
|
|
|
/** |
74
|
15 |
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getName() |
77
|
|
|
{ |
78
|
|
|
return $this->name; |
79
|
|
|
} |
80
|
|
|
|
81
|
8 |
|
/** |
82
|
|
|
* @param string $name Field name |
83
|
8 |
|
* @return $this |
84
|
8 |
|
*/ |
85
|
|
|
public function setName($name) |
86
|
|
|
{ |
87
|
|
|
$this->name = $name; |
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
40 |
|
|
91
|
|
|
/** |
92
|
40 |
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getType() |
95
|
|
|
{ |
96
|
|
|
return $this->type; |
97
|
|
|
} |
98
|
|
|
|
99
|
29 |
|
/** |
100
|
|
|
* @param string $type Field type |
101
|
29 |
|
* @return $this |
102
|
29 |
|
*/ |
103
|
|
|
public function setType($type) |
104
|
|
|
{ |
105
|
|
|
$this->type = $type; |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
8 |
|
|
109
|
|
|
/** |
110
|
8 |
|
* @return int |
111
|
|
|
*/ |
112
|
|
|
public function getLength() |
113
|
|
|
{ |
114
|
|
|
return $this->length; |
115
|
|
|
} |
116
|
|
|
|
117
|
2 |
|
/** |
118
|
|
|
* @param int $length Field length |
119
|
2 |
|
* @return $this |
120
|
2 |
|
*/ |
121
|
|
|
public function setLength($length) |
122
|
|
|
{ |
123
|
|
|
$this->length = $length; |
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
11 |
|
|
127
|
|
|
/** |
128
|
11 |
|
* @return string |
129
|
|
|
*/ |
130
|
|
|
public function getTitle() |
131
|
|
|
{ |
132
|
|
|
return $this->title; |
133
|
|
|
} |
134
|
|
|
|
135
|
3 |
|
/** |
136
|
|
|
* @param string $title Field title |
137
|
3 |
|
* @return $this |
138
|
3 |
|
*/ |
139
|
|
|
public function setTitle($title) |
140
|
|
|
{ |
141
|
|
|
$this->title = $title; |
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
11 |
|
|
145
|
|
|
/** |
146
|
11 |
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public function getDescription() |
149
|
|
|
{ |
150
|
|
|
return $this->description; |
151
|
|
|
} |
152
|
|
|
|
153
|
6 |
|
/** |
154
|
|
|
* @param string $description Field description |
155
|
6 |
|
* @return $this |
156
|
6 |
|
*/ |
157
|
|
|
public function setDescription($description) |
158
|
|
|
{ |
159
|
|
|
$this->description = $description; |
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
9 |
|
|
163
|
|
|
/** |
164
|
9 |
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
public function getExposeAs() |
167
|
|
|
{ |
168
|
|
|
return $this->exposeAs; |
169
|
|
|
} |
170
|
|
|
|
171
|
5 |
|
/** |
172
|
|
|
* @param string $exposeAs Expose field as ... |
173
|
5 |
|
* @return $this |
174
|
5 |
|
*/ |
175
|
|
|
public function setExposeAs($exposeAs) |
176
|
|
|
{ |
177
|
|
|
$this->exposeAs = $exposeAs; |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
9 |
|
|
181
|
|
|
/** |
182
|
9 |
|
* @return bool |
183
|
|
|
*/ |
184
|
|
|
public function getReadOnly() |
|
|
|
|
185
|
|
|
{ |
186
|
|
|
return $this->readOnly; |
187
|
|
|
} |
188
|
|
|
|
189
|
3 |
|
/** |
190
|
|
|
* @param bool $readOnly Is field readonly |
191
|
3 |
|
* @return $this |
192
|
3 |
|
*/ |
193
|
|
|
public function setReadOnly($readOnly) |
194
|
|
|
{ |
195
|
|
|
$this->readOnly = $readOnly; |
196
|
|
|
return $this; |
197
|
|
|
} |
198
|
9 |
|
|
199
|
|
|
/** |
200
|
9 |
|
* @return bool |
201
|
|
|
*/ |
202
|
|
|
public function getRequired() |
|
|
|
|
203
|
|
|
{ |
204
|
|
|
return $this->required; |
205
|
|
|
} |
206
|
|
|
|
207
|
5 |
|
/** |
208
|
|
|
* @param bool $required Is field required |
209
|
5 |
|
* @return $this |
210
|
5 |
|
*/ |
211
|
|
|
public function setRequired($required) |
212
|
|
|
{ |
213
|
|
|
$this->required = $required; |
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
8 |
|
|
217
|
|
|
/** |
218
|
8 |
|
* @return bool |
219
|
|
|
*/ |
220
|
|
|
public function getTranslatable() |
|
|
|
|
221
|
|
|
{ |
222
|
|
|
return $this->translatable; |
223
|
|
|
} |
224
|
|
|
|
225
|
2 |
|
/** |
226
|
|
|
* @param bool $translatable Is field translatable |
227
|
2 |
|
* @return $this |
228
|
2 |
|
*/ |
229
|
|
|
public function setTranslatable($translatable) |
230
|
|
|
{ |
231
|
|
|
$this->translatable = $translatable; |
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
8 |
|
|
235
|
|
|
/** |
236
|
8 |
|
* @return Constraint[] |
237
|
|
|
*/ |
238
|
|
|
public function getConstraints() |
239
|
|
|
{ |
240
|
|
|
return $this->constraints; |
241
|
|
|
} |
242
|
|
|
|
243
|
2 |
|
/** |
244
|
|
|
* @param Constraint[] $constraints Field constraints |
245
|
2 |
|
* @return $this |
246
|
2 |
|
*/ |
247
|
|
|
public function setConstraints(array $constraints) |
248
|
|
|
{ |
249
|
|
|
$this->constraints = $constraints; |
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
8 |
|
|
253
|
|
|
/** |
254
|
8 |
|
* @return array |
255
|
|
|
*/ |
256
|
|
|
public function getCollection() |
257
|
|
|
{ |
258
|
|
|
return $this->collection; |
259
|
|
|
} |
260
|
|
|
|
261
|
2 |
|
/** |
262
|
|
|
* @param array $collection Field |
263
|
2 |
|
* @return $this |
264
|
2 |
|
*/ |
265
|
|
|
public function setCollection(array $collection) |
266
|
|
|
{ |
267
|
|
|
$this->collection = $collection; |
268
|
|
|
return $this; |
269
|
|
|
} |
270
|
8 |
|
|
271
|
|
|
/** |
272
|
8 |
|
* @return XDynamicKey |
273
|
|
|
*/ |
274
|
|
|
public function getXDynamicKey() |
275
|
|
|
{ |
276
|
|
|
return $this->xDynamicKey; |
277
|
|
|
} |
278
|
|
|
|
279
|
1 |
|
/** |
280
|
|
|
* @param XDynamicKey $xDynamicKey x-dynamic-key field value |
281
|
1 |
|
* @return $this |
282
|
1 |
|
*/ |
283
|
|
|
public function setXDynamicKey(XDynamicKey $xDynamicKey) |
284
|
|
|
{ |
285
|
|
|
$this->xDynamicKey = $xDynamicKey; |
286
|
|
|
return $this; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @return mixed |
291
|
|
|
*/ |
292
|
|
|
public function getSearchable() |
|
|
|
|
293
|
|
|
{ |
294
|
|
|
return $this->searchable; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @param mixed $searchable searchable flag |
299
|
|
|
* |
300
|
|
|
* @return void |
301
|
|
|
*/ |
302
|
|
|
public function setSearchable($searchable) |
303
|
|
|
{ |
304
|
|
|
$this->searchable = $searchable; |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.