1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PlaygroundGame\Service; |
4
|
|
|
|
5
|
|
|
use Zend\ServiceManager\ServiceManagerAwareInterface; |
6
|
|
|
use Zend\Stdlib\ErrorHandler; |
7
|
|
|
|
8
|
|
|
class PostVote extends Game implements ServiceManagerAwareInterface |
9
|
|
|
{ |
10
|
|
|
protected $postvoteMapper; |
11
|
|
|
protected $postvoteformMapper; |
12
|
|
|
protected $postVotePostMapper; |
13
|
|
|
protected $postVoteVoteMapper; |
14
|
|
|
protected $postVotePostElementMapper; |
15
|
|
|
|
16
|
|
|
public function getGameEntity() |
17
|
|
|
{ |
18
|
|
|
return new \PlaygroundGame\Entity\PostVote; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function getPath($post) |
22
|
|
|
{ |
23
|
|
|
$path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR; |
24
|
|
|
$path .= 'game' . $post->getPostVote()->getId() . DIRECTORY_SEPARATOR; |
25
|
|
|
if (!is_dir($path)) { |
26
|
|
|
mkdir($path, 0777, true); |
27
|
|
|
} |
28
|
|
|
$path .= 'post'. $post->getId() . DIRECTORY_SEPARATOR; |
29
|
|
|
if (!is_dir($path)) { |
30
|
|
|
mkdir($path, 0777, true); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
return $path; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getMediaUrl($post) |
37
|
|
|
{ |
38
|
|
|
$media_url = $this->getOptions()->getMediaUrl() . '/'; |
39
|
|
|
$media_url .= 'game' . $post->getPostVote()->getId() . '/' . 'post'. $post->getId() . '/'; |
40
|
|
|
|
41
|
|
|
return $media_url; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function checkPost($entry) |
45
|
|
|
{ |
46
|
|
|
$post = $this->getPostVotePostMapper()->findOneBy(array('entry' => $entry)); |
47
|
|
|
|
48
|
|
|
if (! $post) { |
49
|
|
|
$post = new \PlaygroundGame\Entity\PostVotePost(); |
50
|
|
|
$post->setPostvote($entry->getGame()); |
51
|
|
|
$post->setUser($entry->getUser()); |
52
|
|
|
$post->setEntry($entry); |
53
|
|
|
$post = $this->getPostVotePostMapper()->insert($post); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return $post; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function uploadFileToPost($data, $game, $user) |
60
|
|
|
{ |
61
|
|
|
$result = false; |
62
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
63
|
|
|
|
64
|
|
|
if (!$entry) { |
65
|
|
|
return '0'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$post = $this->checkPost($entry); |
69
|
|
|
$path = $this->getPath($post); |
70
|
|
|
$media_url = $this->getMediaUrl($post); |
71
|
|
|
|
72
|
|
|
$key = key($data); |
73
|
|
|
$uploadFile = $this->uploadFile($path, $data[$key]); |
74
|
|
|
|
75
|
|
|
if ($uploadFile) { |
76
|
|
|
$postElement = $this->getPostVotePostElementMapper()->findOneBy(array('post' => $post, 'name' => $key)); |
77
|
|
|
if (! $postElement) { |
78
|
|
|
$postElement = new \PlaygroundGame\Entity\PostVotePostElement(); |
79
|
|
|
} |
80
|
|
|
$postElement->setName($key); |
81
|
|
|
$postElement->setPosition(0); |
82
|
|
|
$postElement->setValue($media_url.$uploadFile); |
83
|
|
|
$postElement->setPost($post); |
84
|
|
|
$postElement = $this->getPostVotePostElementMapper()->insert($postElement); |
|
|
|
|
85
|
|
|
|
86
|
|
|
$result = $media_url.$uploadFile; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
return $result; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function deleteFilePosted($data, $game, $user) |
93
|
|
|
{ |
94
|
|
|
$postvotePostMapper = $this->getPostVotePostMapper(); |
95
|
|
|
$postVotePostElementMapper = $this->getPostVotePostElementMapper(); |
96
|
|
|
|
97
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
98
|
|
|
|
99
|
|
|
if (!$entry) { |
100
|
|
|
return 'falsefin0'; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
$post = $postvotePostMapper->findOneBy(array('entry' => $entry)); |
104
|
|
|
$element = $postVotePostElementMapper->findOneBy(array('post' => $post->getId(), 'name' => $data['name'])); |
105
|
|
|
|
106
|
|
|
if ($element) { |
107
|
|
|
$element = $postVotePostElementMapper->remove($element); |
108
|
|
|
if ($element) { |
109
|
|
|
return true; |
110
|
|
|
} else { |
111
|
|
|
return false; |
112
|
|
|
} |
113
|
|
|
} else { |
114
|
|
|
return false; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* |
120
|
|
|
* @param array $data |
121
|
|
|
* @return \PlaygroundGame\Entity\Game |
122
|
|
|
*/ |
123
|
|
|
public function createPost(array $data, $game, $user, $form) |
124
|
|
|
{ |
125
|
|
|
$postvotePostMapper = $this->getPostVotePostMapper(); |
126
|
|
|
$postVotePostElementMapper = $this->getPostVotePostElementMapper(); |
127
|
|
|
|
128
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
129
|
|
|
|
130
|
|
|
if (!$entry) { |
131
|
|
|
return false; |
|
|
|
|
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
$post = $this->checkPost($entry); |
135
|
|
|
$path = $this->getPath($post); |
136
|
|
|
$media_url = $this->getMediaUrl($post); |
137
|
|
|
$position=1; |
138
|
|
|
|
139
|
|
|
foreach ($data as $name => $value) { |
140
|
|
|
$postElement = $postVotePostElementMapper->findOneBy(array('post' => $post, 'name' => $name)); |
141
|
|
|
if (! $postElement) { |
142
|
|
|
$postElement = new \PlaygroundGame\Entity\PostVotePostElement(); |
143
|
|
|
} |
144
|
|
|
$postElement->setName($name); |
145
|
|
|
$postElement->setPosition($position); |
146
|
|
|
|
147
|
|
|
if (is_array($value) && isset($value['tmp_name'])) { |
148
|
|
|
// The file upload has been done in ajax but some weird bugs remain without it |
149
|
|
|
|
150
|
|
|
if (! $value['error']) { |
151
|
|
|
ErrorHandler::start(); |
152
|
|
|
$value['name'] = $this->fileNewname($path, $value['name'], true); |
153
|
|
|
move_uploaded_file($value['tmp_name'], $path . $value['name']); |
154
|
|
|
$image = $this->getServiceManager()->get('playgroundcore_image_service'); |
155
|
|
|
$image->setImage($path . $value['name']); |
156
|
|
|
|
157
|
|
|
if ($image->canCorrectOrientation()) { |
158
|
|
|
$image->correctOrientation()->save(); |
159
|
|
|
} |
160
|
|
|
$postElement->setValue($media_url . $value['name']); |
161
|
|
|
|
162
|
|
|
if (class_exists("Imagick")) { |
163
|
|
|
$ext = pathinfo($value['name'], PATHINFO_EXTENSION); |
164
|
|
|
$img = new \Imagick($path . $value['name']); |
165
|
|
|
$img->cropThumbnailImage(100, 100); |
166
|
|
|
$img->setImageCompression(\Imagick::COMPRESSION_JPEG); |
167
|
|
|
$img->setImageCompressionQuality(75); |
168
|
|
|
// Strip out unneeded meta data |
169
|
|
|
$img->stripImage(); |
170
|
|
|
$img->writeImage($path . str_replace('.'.$ext, '-thumbnail.'.$ext, $value['name'])); |
171
|
|
|
ErrorHandler::stop(true); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
} elseif (is_array($value)) { |
175
|
|
|
$arValues = $form->get($name)->getValueOptions(); |
176
|
|
|
$postElement->setValue($arValues[$value[0]]); |
177
|
|
|
} elseif (!empty($value)) { |
178
|
|
|
$postElement->setValue($value); |
179
|
|
|
} |
180
|
|
|
$postElement->setPost($post); |
181
|
|
|
$postVotePostElementMapper->insert($postElement); |
182
|
|
|
$position++; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
$postvotePostMapper->update($post); |
186
|
|
|
|
187
|
|
|
// If a preview step is not proposed, I confirmPost on this step |
188
|
|
|
$steps = $game->getStepsArray(); |
189
|
|
|
$previewKey = array_search('preview', $steps); |
190
|
|
|
if (!$previewKey) { |
191
|
|
|
$post = $this->confirmPost($game, $user); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
$this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array( |
195
|
|
|
'user' => $user, |
196
|
|
|
'game' => $game, |
197
|
|
|
'post' => $post, |
198
|
|
|
'entry' => $entry |
199
|
|
|
)); |
200
|
|
|
|
201
|
|
|
return $post; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* |
206
|
|
|
* @return \PlaygroundGame\Entity\Game |
207
|
|
|
*/ |
208
|
|
|
public function confirmPost($game, $user) |
209
|
|
|
{ |
210
|
|
|
$postvotePostMapper = $this->getPostVotePostMapper(); |
211
|
|
|
|
212
|
|
|
$entryMapper = $this->getEntryMapper(); |
213
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
214
|
|
|
|
215
|
|
|
if (!$entry) { |
216
|
|
|
return false; |
|
|
|
|
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
$post = $postvotePostMapper->findOneBy(array('entry' => $entry)); |
220
|
|
|
|
221
|
|
|
if (! $post) { |
222
|
|
|
return false; |
|
|
|
|
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
// The post is confirmed by user. I update the status and close the associated entry |
226
|
|
|
// Post are validated by default, unless pre-moderation is enable for the game |
227
|
|
|
if ($game->getModerationType()) { |
228
|
|
|
$post->setStatus(1); |
229
|
|
|
} else { |
230
|
|
|
$post->setStatus(2); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
$postvotePostMapper->update($post); |
234
|
|
|
|
235
|
|
|
$entry->setActive(0); |
|
|
|
|
236
|
|
|
$entryMapper->update($entry); |
237
|
|
|
|
238
|
|
|
$this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array( |
239
|
|
|
'user' => $user, |
240
|
|
|
'game' => $game, |
241
|
|
|
'entry' => $entry, |
242
|
|
|
'post' => $post |
243
|
|
|
)); |
244
|
|
|
|
245
|
|
|
if ($user) { |
246
|
|
|
// send mail for participation |
247
|
|
|
$this->sendGameMail($game, $user, $post, 'postvote'); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
return $post; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* |
255
|
|
|
* This service is ready for all types of games |
256
|
|
|
* |
257
|
|
|
* @param array $data |
258
|
|
|
* @return \PlaygroundGame\Entity\Game |
259
|
|
|
*/ |
260
|
|
View Code Duplication |
public function createForm(array $data, $game, $form = null) |
|
|
|
|
261
|
|
|
{ |
262
|
|
|
$title =''; |
263
|
|
|
$description = ''; |
264
|
|
|
|
265
|
|
|
if ($data['form_jsonified']) { |
266
|
|
|
$jsonPV = json_decode($data['form_jsonified']); |
267
|
|
|
foreach ($jsonPV as $element) { |
268
|
|
|
if ($element->form_properties) { |
269
|
|
|
$attributes = $element->form_properties[0]; |
270
|
|
|
$title = $attributes->title; |
271
|
|
|
$description = $attributes->description; |
272
|
|
|
|
273
|
|
|
break; |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
} |
277
|
|
|
if (!$form) { |
278
|
|
|
$form = new \PlaygroundGame\Entity\PostVoteForm(); |
279
|
|
|
} |
280
|
|
|
$form->setPostvote($game); |
281
|
|
|
$form->setTitle($title); |
282
|
|
|
$form->setDescription($description); |
283
|
|
|
$form->setForm($data['form_jsonified']); |
284
|
|
|
$form->setFormTemplate($data['form_template']); |
285
|
|
|
|
286
|
|
|
$form = $this->getPostVoteFormMapper()->insert($form); |
287
|
|
|
|
288
|
|
|
return $form; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
public function findArrayOfValidatedPosts($game, $filter, $search = '') |
292
|
|
|
{ |
293
|
|
|
$em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default'); |
294
|
|
|
$qb = $em->createQueryBuilder(); |
295
|
|
|
$and = $qb->expr()->andx(); |
296
|
|
|
|
297
|
|
|
$and->add($qb->expr()->eq('p.status', 2)); |
298
|
|
|
|
299
|
|
|
$and->add($qb->expr()->eq('g.id', ':game')); |
300
|
|
|
$qb->setParameter('game', $game); |
301
|
|
|
|
302
|
|
|
if ($search != '') { |
303
|
|
|
$and->add( |
304
|
|
|
$qb->expr()->orX( |
305
|
|
|
$qb->expr()->like('u.username', $qb->expr()->literal('%:search%')), |
306
|
|
|
$qb->expr()->like('u.firstname', $qb->expr()->literal('%:search%')), |
307
|
|
|
$qb->expr()->like('u.lastname', $qb->expr()->literal('%:search%')), |
308
|
|
|
$qb->expr()->like('e.value', $qb->expr()->literal('%:search%')), |
309
|
|
|
$qb->expr()->isNull('g.publicationDate') |
310
|
|
|
) |
311
|
|
|
); |
312
|
|
|
$qb->setParameter('search', $search); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
if ('push' == $filter) { |
316
|
|
|
$and->add( |
317
|
|
|
$qb->expr()->andX( |
318
|
|
|
$qb->expr()->eq('p.pushed', 1) |
319
|
|
|
) |
320
|
|
|
); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
$qb->select('p, COUNT(v) AS votesCount') |
324
|
|
|
->from('PlaygroundGame\Entity\PostVotePost', 'p') |
325
|
|
|
->innerJoin('p.postvote', 'g') |
326
|
|
|
->leftJoin('p.user', 'u') |
327
|
|
|
->innerJoin('p.postElements', 'e') |
328
|
|
|
->leftJoin('p.votes', 'v') |
329
|
|
|
->where($and) |
330
|
|
|
->groupBy('p.id'); |
331
|
|
|
|
332
|
|
|
switch ($filter) { |
333
|
|
|
case 'random': |
334
|
|
|
$qb->orderBy('e.value', 'ASC'); |
335
|
|
|
break; |
336
|
|
|
case 'vote': |
337
|
|
|
$qb->orderBy('votesCount', 'DESC'); |
338
|
|
|
break; |
339
|
|
|
case 'date': |
340
|
|
|
$qb->orderBy('p.createdAt', 'DESC'); |
341
|
|
|
break; |
342
|
|
|
case 'push': |
343
|
|
|
$qb->orderBy('p.createdAt', 'DESC'); |
344
|
|
|
break; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
$query = $qb->getQuery(); |
348
|
|
|
|
349
|
|
|
$posts = $query->getResult(); |
350
|
|
|
$arrayPosts = array(); |
351
|
|
|
$i=0; |
352
|
|
|
foreach ($posts as $postRaw) { |
353
|
|
|
$data = array(); |
354
|
|
|
$post = $postRaw[0]; |
355
|
|
|
if ($post) { |
356
|
|
|
foreach ($post->getPostElements() as $element) { |
357
|
|
|
$data[$element->getPosition()] = $element->getValue(); |
358
|
|
|
} |
359
|
|
|
$arrayPosts[$i]['data'] = $data; |
360
|
|
|
$arrayPosts[$i]['votes'] = count($post->getVotes()); |
361
|
|
|
$arrayPosts[$i]['id'] = $post->getId(); |
362
|
|
|
$arrayPosts[$i]['user'] = $post->getUser(); |
363
|
|
|
$arrayPosts[$i]['createdAt'] = $post->getCreatedAt(); |
364
|
|
|
$i++; |
365
|
|
|
} |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
return $arrayPosts; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
public function addVote($user, $ipAddress, $post) |
372
|
|
|
{ |
373
|
|
|
$postvoteVoteMapper = $this->getPostVoteVoteMapper(); |
374
|
|
|
$postId = $post->getId(); |
375
|
|
|
|
376
|
|
|
if ($user) { |
377
|
|
|
$userId = $user->getId(); |
378
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('userId' => $userId, 'post' =>$postId))); |
379
|
|
|
} else { |
380
|
|
|
$entryUser =count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' =>$postId))); |
381
|
|
|
} |
382
|
|
|
if ($entryUser && $entryUser > 0) { |
383
|
|
|
return false; |
384
|
|
|
} else { |
385
|
|
|
$vote = new \PlaygroundGame\Entity\PostVoteVote(); |
386
|
|
|
$vote->setPost($post); |
387
|
|
|
$vote->setIp($ipAddress); |
388
|
|
|
if ($user) { |
389
|
|
|
$vote->setUserId($user->getId()); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
$postvoteVoteMapper->insert($vote); |
393
|
|
|
$game = $post->getPostvote(); |
394
|
|
|
$this->getEventManager()->trigger( |
395
|
|
|
'vote_postvote.post', |
396
|
|
|
$this, |
397
|
|
|
array('user' => $user, 'game' => $game, 'post' => $post, 'vote' => $vote) |
398
|
|
|
); |
399
|
|
|
|
400
|
|
|
return true; |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
public function getEntriesHeader($game) |
405
|
|
|
{ |
406
|
|
|
$header = parent::getEntriesHeader($game); |
407
|
|
|
if ($game->getForm()) { |
408
|
|
|
$form = json_decode($game->getForm()->getForm(), true); |
409
|
|
View Code Duplication |
foreach ($form as $element) { |
|
|
|
|
410
|
|
|
foreach ($element as $k => $v) { |
411
|
|
|
if ($k !== 'form_properties') { |
412
|
|
|
$header[$v[0]['name']] = 1; |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
return $header; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
View Code Duplication |
public function getEntriesQuery($game) |
|
|
|
|
422
|
|
|
{ |
423
|
|
|
$em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default'); |
424
|
|
|
|
425
|
|
|
$qb = $em->createQueryBuilder(); |
426
|
|
|
$qb->select(' |
427
|
|
|
p.id, |
428
|
|
|
u.username, |
429
|
|
|
u.title, |
430
|
|
|
u.firstname, |
431
|
|
|
u.lastname, |
432
|
|
|
u.email, |
433
|
|
|
u.optin, |
434
|
|
|
u.optinPartner, |
435
|
|
|
u.address, |
436
|
|
|
u.address2, |
437
|
|
|
u.postalCode, |
438
|
|
|
u.city, |
439
|
|
|
u.telephone, |
440
|
|
|
u.mobile, |
441
|
|
|
u.created_at, |
442
|
|
|
u.dob, |
443
|
|
|
e.winner, |
444
|
|
|
e.socialShares, |
445
|
|
|
e.playerData, |
446
|
|
|
e.updated_at, |
447
|
|
|
p.status, |
448
|
|
|
p |
449
|
|
|
') |
450
|
|
|
->from('PlaygroundGame\Entity\PostVotePost', 'p') |
451
|
|
|
->innerJoin('p.entry', 'e') |
452
|
|
|
->leftJoin('p.user', 'u') |
453
|
|
|
->where($qb->expr()->eq('e.game', ':game')); |
454
|
|
|
|
455
|
|
|
$qb->setParameter('game', $game); |
456
|
|
|
|
457
|
|
|
return $qb->getQuery(); |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* getGameEntries : All entries of a game |
462
|
|
|
* |
463
|
|
|
* @return Array of PlaygroundGame\Entity\Game |
464
|
|
|
*/ |
465
|
|
|
public function getGameEntries($header, $entries, $game) |
466
|
|
|
{ |
467
|
|
|
|
468
|
|
|
$results = array(); |
469
|
|
|
|
470
|
|
|
foreach ($entries as $k => $entry) { |
471
|
|
|
$entryData = json_decode($entry['playerData'], true); |
472
|
|
|
$postElements = $entry[0]->getPostElements(); |
473
|
|
|
|
474
|
|
|
foreach ($header as $key => $v) { |
475
|
|
|
if (isset($entryData[$key]) && $key !=='id') { |
476
|
|
|
$results[$k][$key] = (is_array($entryData[$key]))?implode(', ', $entryData[$key]):$entryData[$key]; |
477
|
|
|
} elseif (array_key_exists($key, $entry)) { |
478
|
|
|
$results[$k][$key] = ($entry[$key] instanceof \DateTime)?$entry[$key]->format('Y-m-d'):$entry[$key]; |
479
|
|
|
} else { |
480
|
|
|
$results[$k][$key] = ''; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
foreach ($postElements as $e) { |
484
|
|
|
if ($key === $e->getName()) { |
485
|
|
|
$results[$k][$key] = (is_array($e->getValue()))?implode(', ', $e->getValue()):$e->getValue(); |
486
|
|
|
break; |
487
|
|
|
} |
488
|
|
|
} |
489
|
|
|
} |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
return $results; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
public function getPostVoteFormMapper() |
496
|
|
|
{ |
497
|
|
|
if (null === $this->postvoteformMapper) { |
498
|
|
|
$this->postvoteformMapper = $this->getServiceManager()->get('playgroundgame_postvoteform_mapper'); |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
return $this->postvoteformMapper; |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
public function setPostVoteFormMapper($postvoteformMapper) |
505
|
|
|
{ |
506
|
|
|
$this->postvoteformMapper = $postvoteformMapper; |
507
|
|
|
|
508
|
|
|
return $this; |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
public function getPostVotePostElementMapper() |
512
|
|
|
{ |
513
|
|
|
if (null === $this->postVotePostElementMapper) { |
514
|
|
|
$this->postVotePostElementMapper = $this->getServiceManager()->get( |
515
|
|
|
'playgroundgame_postvotepostelement_mapper' |
516
|
|
|
); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
return $this->postVotePostElementMapper; |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
public function setPostVotePostElementMapper($postVotePostElementMapper) |
523
|
|
|
{ |
524
|
|
|
$this->postVotePostElementMapper = $postVotePostElementMapper; |
525
|
|
|
|
526
|
|
|
return $this; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
public function getPostVoteVoteMapper() |
530
|
|
|
{ |
531
|
|
|
if (null === $this->postVoteVoteMapper) { |
532
|
|
|
$this->postVoteVoteMapper = $this->getServiceManager()->get('playgroundgame_postvotevote_mapper'); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
return $this->postVoteVoteMapper; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
public function setPostVoteVoteMapper($postVoteVoteMapper) |
539
|
|
|
{ |
540
|
|
|
$this->postVoteVoteMapper = $postVoteVoteMapper; |
541
|
|
|
|
542
|
|
|
return $this; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
public function getPostVotePostMapper() |
546
|
|
|
{ |
547
|
|
|
if (null === $this->postVotePostMapper) { |
548
|
|
|
$this->postVotePostMapper = $this->getServiceManager()->get('playgroundgame_postvotepost_mapper'); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
return $this->postVotePostMapper; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
public function setPostVotePostMapper($postVotePostMapper) |
555
|
|
|
{ |
556
|
|
|
$this->postVotePostMapper = $postVotePostMapper; |
557
|
|
|
|
558
|
|
|
return $this; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
public function getPostVoteMapper() |
562
|
|
|
{ |
563
|
|
|
if (null === $this->postvoteMapper) { |
564
|
|
|
$this->postvoteMapper = $this->getServiceManager()->get('playgroundgame_postvote_mapper'); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
return $this->postvoteMapper; |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* setQuizQuestionMapper |
572
|
|
|
* |
573
|
|
|
* @return PostVote |
574
|
|
|
*/ |
575
|
|
|
public function setPostVoteMapper($postvoteMapper) |
576
|
|
|
{ |
577
|
|
|
$this->postvoteMapper = $postvoteMapper; |
578
|
|
|
|
579
|
|
|
return $this; |
580
|
|
|
} |
581
|
|
|
} |
582
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.