|
1
|
|
|
<?php |
|
2
|
|
|
namespace PlaygroundGame\Entity; |
|
3
|
|
|
|
|
4
|
|
|
use PlaygroundGame\Entity\Game; |
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
|
7
|
|
|
use Gedmo\Translatable\Translatable; |
|
8
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks; |
|
9
|
|
|
use Zend\InputFilter\InputFilter; |
|
10
|
|
|
use Zend\InputFilter\Factory as InputFactory; |
|
11
|
|
|
use Zend\InputFilter\InputFilterAwareInterface; |
|
12
|
|
|
use Zend\InputFilter\InputFilterInterface; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
|
16
|
|
|
* @ORM\Table(name="game_instantwin") |
|
17
|
|
|
*/ |
|
18
|
|
|
class InstantWin extends Game implements InputFilterAwareInterface |
|
19
|
|
|
{ |
|
20
|
|
|
const CLASSTYPE = 'instantwin'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* values : datetime - dates of win |
|
24
|
|
|
* code - winning and loosing codes are registered for the game |
|
25
|
|
|
* visit - a winning is triggered every n visits, |
|
26
|
|
|
* random - Not set by default : The number of wins is set and it's triggered randomly |
|
27
|
|
|
* based on number of visitors + duration of game + number of wins |
|
28
|
|
|
* |
|
29
|
|
|
* @ORM\Column(name="occurrence_type", type="string", nullable=false) |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $occurrenceType = 'datetime'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Automatic Draw |
|
35
|
|
|
* @ORM\Column(name="schedule_occurrence_auto", type="boolean", nullable=false) |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $scheduleOccurrenceAuto = 0; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Determine how much occurrences to create |
|
41
|
|
|
* |
|
42
|
|
|
* @ORM\Column(name="occurrence_number", type="integer", nullable=true) |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $occurrenceNumber = 0; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Determine how much winning occurrences to create among the occurrences |
|
48
|
|
|
* |
|
49
|
|
|
* @ORM\Column(name="winning_occurrence_number", type="integer", nullable=true) |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $winningOccurrenceNumber = 0; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* this field is taken into account only if $occurrenceNumber<>0. |
|
55
|
|
|
* if 'game' $occurrenceNumber are drawn between game start date and game end date |
|
56
|
|
|
* if 'hour' $occurrenceNumber are drawn a hour between game start date and game end date |
|
57
|
|
|
* if 'day' $occurrenceNumber are drawn a day for each day between game start date and game end date |
|
58
|
|
|
* if 'week' $occurrenceNumber are drawn a week between game start date and game end date |
|
59
|
|
|
* if 'month' $occurrenceNumber are drawn a month between game start date and game end date |
|
60
|
|
|
* |
|
61
|
|
|
* @ORM\Column(name="occurrence_draw_frequency", type="string", nullable=true) |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $occurrenceDrawFrequency; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @Gedmo\Translatable |
|
67
|
|
|
* @ORM\Column(name="scratchcard_image", type="string", length=255, nullable=true) |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $scratchcardImage; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @ORM\OneToMany(targetEntity="InstantWinOccurrence", mappedBy="instant_win") |
|
73
|
|
|
**/ |
|
74
|
|
|
private $occurrences; |
|
75
|
|
|
|
|
76
|
|
|
public function __construct() |
|
77
|
|
|
{ |
|
78
|
|
|
parent::__construct(); |
|
79
|
|
|
$this->setClassType(self::CLASSTYPE); |
|
80
|
|
|
$this->occurrences = new \Doctrine\Common\Collections\ArrayCollection(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
*/ |
|
85
|
|
|
public function setOccurrences($occurrences) |
|
86
|
|
|
{ |
|
87
|
|
|
$this->occurrences = $occurrences; |
|
88
|
|
|
|
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get question. |
|
94
|
|
|
* |
|
95
|
|
|
* @return \Doctrine\Common\Collections\Collection |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getOccurrences() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->occurrences; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Add a question to the quiz. |
|
104
|
|
|
* |
|
105
|
|
|
* |
|
106
|
|
|
* @return void |
|
107
|
|
|
*/ |
|
108
|
|
|
public function addOccurrence($occurrence) |
|
109
|
|
|
{ |
|
110
|
|
|
$this->occurrences[] = $occurrence; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @return string unknown_type |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getOccurrenceType() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->occurrenceType; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param unknown_type $occurrenceType |
|
123
|
|
|
*/ |
|
124
|
|
|
public function setOccurrenceType($occurrenceType) |
|
125
|
|
|
{ |
|
126
|
|
|
$this->occurrenceType = $occurrenceType; |
|
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
return $this; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return the unknown_type |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getOccurrenceNumber() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->occurrenceNumber; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @param unknown_type $occurrenceNumber |
|
141
|
|
|
*/ |
|
142
|
|
|
public function setOccurrenceNumber($occurrenceNumber) |
|
143
|
|
|
{ |
|
144
|
|
|
$this->occurrenceNumber = $occurrenceNumber; |
|
|
|
|
|
|
145
|
|
|
|
|
146
|
|
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
/** |
|
149
|
|
|
* @return the unknown_type |
|
150
|
|
|
*/ |
|
151
|
|
|
public function getWinningOccurrenceNumber() |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->winningOccurrenceNumber; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param unknown_type $winningOccurrenceNumber |
|
158
|
|
|
*/ |
|
159
|
|
|
public function setWinningOccurrenceNumber($winningOccurrenceNumber) |
|
160
|
|
|
{ |
|
161
|
|
|
$this->winningOccurrenceNumber = $winningOccurrenceNumber; |
|
|
|
|
|
|
162
|
|
|
|
|
163
|
|
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @return the unknown_type |
|
168
|
|
|
*/ |
|
169
|
|
|
public function getOccurrenceDrawFrequency() |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->occurrenceDrawFrequency; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @param unknown_type $occurrenceDrawFrequency |
|
176
|
|
|
*/ |
|
177
|
|
|
public function setOccurrenceDrawFrequency($occurrenceDrawFrequency) |
|
178
|
|
|
{ |
|
179
|
|
|
$this->occurrenceDrawFrequency = $occurrenceDrawFrequency; |
|
180
|
|
|
|
|
181
|
|
|
return $this; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @return integer unknown_type |
|
186
|
|
|
*/ |
|
187
|
|
|
public function getScheduleOccurrenceAuto() |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->scheduleOccurrenceAuto; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @param unknown_type $scheduleOccurrenceAuto |
|
194
|
|
|
*/ |
|
195
|
|
|
public function setScheduleOccurrenceAuto($scheduleOccurrenceAuto) |
|
196
|
|
|
{ |
|
197
|
|
|
$this->scheduleOccurrenceAuto = $scheduleOccurrenceAuto; |
|
|
|
|
|
|
198
|
|
|
|
|
199
|
|
|
return $this; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* |
|
204
|
|
|
* @return the $scratchcardImage |
|
205
|
|
|
*/ |
|
206
|
|
|
public function getScratchcardImage() |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->scratchcardImage; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* |
|
213
|
|
|
* @param field_type $scratchcardImage |
|
214
|
|
|
*/ |
|
215
|
|
|
public function setScratchcardImage($scratchcardImage) |
|
216
|
|
|
{ |
|
217
|
|
|
$this->scratchcardImage = $scratchcardImage; |
|
218
|
|
|
|
|
219
|
|
|
return $this; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* Convert the object to an array. |
|
224
|
|
|
* |
|
225
|
|
|
* @return array |
|
226
|
|
|
*/ |
|
227
|
|
|
public function getArrayCopy() |
|
228
|
|
|
{ |
|
229
|
|
|
$obj_vars = parent::getArrayCopy(); |
|
230
|
|
|
array_merge($obj_vars, get_object_vars($this)); |
|
231
|
|
|
|
|
232
|
|
|
return $obj_vars; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Populate from an array. |
|
237
|
|
|
* |
|
238
|
|
|
* @param array $data |
|
239
|
|
|
*/ |
|
240
|
|
|
public function populate($data = array()) |
|
241
|
|
|
{ |
|
242
|
|
|
parent::populate($data); |
|
243
|
|
|
|
|
244
|
|
|
if (isset($data['scheduleOccurrenceAuto']) && $data['scheduleOccurrenceAuto'] !== null) { |
|
245
|
|
|
$this->scheduleOccurrenceAuto = $data['scheduleOccurrenceAuto']; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
View Code Duplication |
if (isset($data['occurrenceNumber']) && $data['occurrenceNumber'] !== null) { |
|
|
|
|
|
|
249
|
|
|
$this->occurrenceNumber = $data['occurrenceNumber']; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
View Code Duplication |
if (isset($data['winningOccurrenceNumber']) && $data['winningOccurrenceNumber'] !== null) { |
|
|
|
|
|
|
253
|
|
|
$this->occurrenceNumber = $data['winningOccurrenceNumber']; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
if (isset($data['occurrenceType']) && $data['occurrenceType'] !== null) { |
|
257
|
|
|
$this->occurrenceType = $data['occurrenceType']; |
|
258
|
|
|
} |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
public function setInputFilter(InputFilterInterface $inputFilter) |
|
262
|
|
|
{ |
|
263
|
|
|
throw new \Exception("Not used"); |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
public function getInputFilter() |
|
267
|
|
|
{ |
|
268
|
|
|
if (!$this->inputFilter) { |
|
269
|
|
|
$inputFilter = new InputFilter(); |
|
|
|
|
|
|
270
|
|
|
$factory = new InputFactory(); |
|
271
|
|
|
|
|
272
|
|
|
$inputFilter = parent::getInputFilter(); |
|
273
|
|
|
|
|
274
|
|
|
$inputFilter->add( |
|
275
|
|
|
$factory->createInput( |
|
276
|
|
|
array( |
|
277
|
|
|
'name' => 'id', |
|
278
|
|
|
'required' => true, |
|
279
|
|
|
'filters' => array(array('name' => 'Int')) |
|
280
|
|
|
) |
|
281
|
|
|
) |
|
282
|
|
|
); |
|
283
|
|
|
|
|
284
|
|
|
$inputFilter->add($factory->createInput(array( |
|
285
|
|
|
'name' => 'occurrenceNumber', |
|
286
|
|
|
'required' => false, |
|
287
|
|
|
'validators' => array( |
|
288
|
|
|
array('name' => 'Digits'), |
|
289
|
|
|
), |
|
290
|
|
|
))); |
|
291
|
|
|
|
|
292
|
|
|
$inputFilter->add($factory->createInput(array( |
|
293
|
|
|
'name' => 'winningOccurrenceNumber', |
|
294
|
|
|
'required' => false, |
|
295
|
|
|
'validators' => array( |
|
296
|
|
|
array('name' => 'Digits'), |
|
297
|
|
|
), |
|
298
|
|
|
))); |
|
299
|
|
|
|
|
300
|
|
|
$inputFilter->add($factory->createInput(array( |
|
301
|
|
|
'name' => 'occurrenceDrawFrequency', |
|
302
|
|
|
'required' => false, |
|
303
|
|
|
'validators' => array( |
|
304
|
|
|
array( |
|
305
|
|
|
'name' => 'InArray', |
|
306
|
|
|
'options' => array( |
|
307
|
|
|
'haystack' => array('hour', 'day', 'week', 'month', 'game'), |
|
308
|
|
|
), |
|
309
|
|
|
), |
|
310
|
|
|
), |
|
311
|
|
|
))); |
|
312
|
|
|
|
|
313
|
|
|
$inputFilter->add($factory->createInput(array( |
|
314
|
|
|
'name' => 'occurrenceType', |
|
315
|
|
|
'required' => true, |
|
316
|
|
|
'validators' => array( |
|
317
|
|
|
array( |
|
318
|
|
|
'name' => 'InArray', |
|
319
|
|
|
'options' => array( |
|
320
|
|
|
'haystack' => array('datetime', 'code', 'visitor', 'random'), |
|
321
|
|
|
), |
|
322
|
|
|
), |
|
323
|
|
|
), |
|
324
|
|
|
))); |
|
325
|
|
|
|
|
326
|
|
|
$this->inputFilter = $inputFilter; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
return $this->inputFilter; |
|
330
|
|
|
} |
|
331
|
|
|
} |
|
332
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..