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