Completed
Push — develop ( 54744b...29957b )
by greg
03:57
created

PostVote::getEntriesQuery()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 10

Duplication

Lines 37
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 37
loc 37
rs 8.8571
cc 1
eloc 10
nc 1
nop 1
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) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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);
0 ignored issues
show
Unused Code introduced by
$postElement is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

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.

Loading history...
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;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\PostVote::createPost of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
114
        }
115
116
        $post = $postvotePostMapper->findOneBy(array('entry' => $entry));
117
118 View Code Duplication
        if (! $post) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\PostVote::confirmPost of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
216
        }
217
218
        $post = $postvotePostMapper->findOneBy(array('entry' => $entry));
219
220
        if (! $post) {
221
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Service\PostVote::confirmPost of type PlaygroundGame\Entity\Game.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
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);
0 ignored issues
show
Bug introduced by
The method setActive cannot be called on $entry (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
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)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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
        $header = parent::getEntriesHeader($game);
401
        if ($game->getForm()) {
402
            $form = json_decode($game->getForm()->getForm(), true);
403 View Code Duplication
            foreach ($form as $element) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
404
                foreach($element as $k => $v){
405
                    if($k !== 'form_properties')
406
                        $header[$v[0]['name']] = 1;
407
                }
408
            }
409
        }
410
411
        return $header;
412
    }
413
414 View Code Duplication
    public function getEntriesQuery($game){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
415
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
416
417
        $qb = $em->createQueryBuilder();
418
        $qb->select('
419
            p.id,
420
            u.username,
421
            u.title,
422
            u.firstname,
423
            u.lastname,
424
            u.email,
425
            u.optin,
426
            u.optinPartner,
427
            u.address,
428
            u.address2,
429
            u.postalCode,
430
            u.city,
431
            u.telephone,
432
            u.mobile,
433
            u.created_at,
434
            u.dob,
435
            e.winner,
436
            e.socialShares,
437
            e.playerData,
438
            e.updated_at,
439
            p.status,
440
            p
441
            ')
442
            ->from('PlaygroundGame\Entity\PostVotePost', 'p')
443
            ->innerJoin('p.entry', 'e')
444
            ->leftJoin('p.user', 'u')
445
            ->where($qb->expr()->eq('e.game', ':game'));
446
        
447
        $qb->setParameter('game', $game);
448
449
        return $qb->getQuery();
450
    }
451
452
    /**
453
    * getGameEntries : All entries of a game
454
    *
455
    * @return Array of PlaygroundGame\Entity\Game
456
    */
457
    public function getGameEntries($header, $entries, $game)
458
    {
459
        
460
        $results = array();
461
462
        foreach ($entries as $k=>$entry) {
463
464
            $entryData = json_decode($entry['playerData'], true);
465
            $postElements = $entry[0]->getPostElements();
466
467
            foreach ($header as $key => $v) {
468
                if (isset($entryData[$key]) && $key !=='id') {
469
                    $results[$k][$key] = (is_array($entryData[$key]))?implode(', ',$entryData[$key]):$entryData[$key];
470
                } elseif (array_key_exists($key,$entry) ){
471
                    $results[$k][$key] = ($entry[$key] instanceof \DateTime)?$entry[$key]->format('Y-m-d'):$entry[$key];
472
                } else {
473
                    $results[$k][$key] = '';
474
                }
475
476
                foreach($postElements as $e){
477
                    if($key === $e->getName()){
478
                        $results[$k][$key] = (is_array($e->getValue()))?implode(', ', $e->getValue()):$e->getValue(); 
479
                        break;
480
                    }
481
                }
482
            }
483
        }
484
485
        return $results;
486
    }
487
488
    public function getPostVoteFormMapper()
489
    {
490
        if (null === $this->postvoteformMapper) {
491
            $this->postvoteformMapper = $this->getServiceManager()->get('playgroundgame_postvoteform_mapper');
492
        }
493
494
        return $this->postvoteformMapper;
495
    }
496
497
    public function setPostVoteFormMapper($postvoteformMapper)
498
    {
499
        $this->postvoteformMapper = $postvoteformMapper;
500
501
        return $this;
502
    }
503
504
    public function getPostVotePostElementMapper()
505
    {
506
        if (null === $this->postVotePostElementMapper) {
507
            $this->postVotePostElementMapper = $this->getServiceManager()->get('playgroundgame_postvotepostelement_mapper');
508
        }
509
510
        return $this->postVotePostElementMapper;
511
    }
512
513
    public function setPostVotePostElementMapper($postVotePostElementMapper)
514
    {
515
        $this->postVotePostElementMapper = $postVotePostElementMapper;
516
517
        return $this;
518
    }
519
520
    public function getPostVoteVoteMapper()
521
    {
522
        if (null === $this->postVoteVoteMapper) {
523
            $this->postVoteVoteMapper = $this->getServiceManager()->get('playgroundgame_postvotevote_mapper');
524
        }
525
526
        return $this->postVoteVoteMapper;
527
    }
528
529
    public function setPostVoteVoteMapper($postVoteVoteMapper)
530
    {
531
        $this->postVoteVoteMapper = $postVoteVoteMapper;
532
533
        return $this;
534
    }
535
536
    public function getPostVotePostMapper()
537
    {
538
        if (null === $this->postVotePostMapper) {
539
            $this->postVotePostMapper = $this->getServiceManager()->get('playgroundgame_postvotepost_mapper');
540
        }
541
542
        return $this->postVotePostMapper;
543
    }
544
545
    public function setPostVotePostMapper($postVotePostMapper)
546
    {
547
        $this->postVotePostMapper = $postVotePostMapper;
548
549
        return $this;
550
    }
551
552
    public function getPostVoteMapper()
553
    {
554
        if (null === $this->postvoteMapper) {
555
            $this->postvoteMapper = $this->getServiceManager()->get('playgroundgame_postvote_mapper');
556
        }
557
558
        return $this->postvoteMapper;
559
    }
560
561
    /**
562
     * setQuizQuestionMapper
563
     *
564
     * @return PostVote
565
     */
566
    public function setPostVoteMapper($postvoteMapper)
567
    {
568
        $this->postvoteMapper = $postvoteMapper;
569
570
        return $this;
571
    }
572
}
573