Completed
Push — develop ( b3b9d6...b879cb )
by greg
19:23 queued 20s
created

PostVote::setPostVoteCommentMapper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
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 $postVoteCommentMapper;
15
    protected $postVotePostElementMapper;
16
17
    public function getGameEntity()
18
    {
19
        return new \PlaygroundGame\Entity\PostVote;
20
    }
21
22
    public function getPath($post)
23
    {
24
        $path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR;
25
        $path .= 'game' . $post->getPostVote()->getId() . DIRECTORY_SEPARATOR;
26
        if (!is_dir($path)) {
27
            mkdir($path, 0777, true);
28
        }
29
        $path .= 'post'. $post->getId() . DIRECTORY_SEPARATOR;
30
        if (!is_dir($path)) {
31
            mkdir($path, 0777, true);
32
        }
33
34
        return $path;
35
    }
36
37
    public function getMediaUrl($post)
38
    {
39
        $media_url = $this->getOptions()->getMediaUrl() . '/';
40
        $media_url .= 'game' . $post->getPostVote()->getId() . '/' . 'post'. $post->getId() . '/';
41
42
        return $media_url;
43
    }
44
45
    /**
46
     * @param boolean $entry
47
     */
48
    public function checkPost($entry)
49
    {
50
        $post = $this->getPostVotePostMapper()->findOneBy(array('entry' => $entry));
51
52
        if (! $post) {
53
            $post = new \PlaygroundGame\Entity\PostVotePost();
54
            $post->setPostvote($entry->getGame());
0 ignored issues
show
Bug introduced by
The method getGame 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...
55
            $post->setUser($entry->getUser());
0 ignored issues
show
Bug introduced by
The method getUser 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...
56
            $post->setEntry($entry);
57
            $post = $this->getPostVotePostMapper()->insert($post);
58
        }
59
60
        return $post;
61
    }
62
63
    public function uploadFileToPost($data, $game, $user)
64
    {
65
        $result = false;
66
        $entry = $this->findLastActiveEntry($game, $user);
67
68
        if (!$entry) {
69
            return '0';
70
        }
71
72
        $post = $this->checkPost($entry);
73
        $path = $this->getPath($post);
74
        $media_url = $this->getMediaUrl($post);
75
76
        $key = key($data);
77
        $uploadFile = $this->uploadFile($path, $data[$key]);
78
79
        if ($uploadFile) {
80
            $postElement = $this->getPostVotePostElementMapper()->findOneBy(array('post' => $post, 'name' => $key));
81
            if (! $postElement) {
82
                $postElement = new \PlaygroundGame\Entity\PostVotePostElement();
83
            }
84
            $postElement->setName($key);
85
            $postElement->setPosition(0);
86
            $postElement->setValue($media_url.$uploadFile);
87
            $postElement->setPost($post);
88
            $postElement = $this->getPostVotePostElementMapper()->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...
89
90
            $result = $media_url.$uploadFile;
91
        }
92
93
        return $result;
94
    }
95
96
    public function deleteFilePosted($data, $game, $user)
97
    {
98
        $postvotePostMapper = $this->getPostVotePostMapper();
99
        $postVotePostElementMapper = $this->getPostVotePostElementMapper();
100
101
        $entry = $this->findLastActiveEntry($game, $user);
102
103
        if (!$entry) {
104
            return 'falsefin0';
105
        }
106
107
        $post = $postvotePostMapper->findOneBy(array('entry' => $entry));
108
        $element = $postVotePostElementMapper->findOneBy(array('post' => $post->getId(), 'name' => $data['name']));
109
110
        if ($element) {
111
            $element = $postVotePostElementMapper->remove($element);
112
            if ($element) {
113
                return true;
114
            } else {
115
                return false;
116
            }
117
        } else {
118
            return false;
119
        }
120
    }
121
122
    /**
123
     *
124
     * @param  array $data
125
     * @return \PlaygroundGame\Entity\Game
126
     */
127
    public function createPost(array $data, $game, $user, $form)
128
    {
129
        $postvotePostMapper = $this->getPostVotePostMapper();
130
        $postVotePostElementMapper = $this->getPostVotePostElementMapper();
131
132
        $entry = $this->findLastActiveEntry($game, $user);
133
134
        if (!$entry) {
135
            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...
136
        }
137
138
        $post = $this->checkPost($entry);
139
        $path = $this->getPath($post);
140
        $media_url = $this->getMediaUrl($post);
141
        $position=1;
142
143
        foreach ($data as $name => $value) {
144
            $postElement = $postVotePostElementMapper->findOneBy(array('post' => $post, 'name' => $name));
145
            if (! $postElement) {
146
                $postElement = new \PlaygroundGame\Entity\PostVotePostElement();
147
            }
148
            $postElement->setName($name);
149
            $postElement->setPosition($position);
150
151
            if (is_array($value) && isset($value['tmp_name'])) {
152
                // The file upload has been done in ajax but some weird bugs remain without it
153
154
                if (! $value['error']) {
155
                    ErrorHandler::start();
156
                    $value['name'] = $this->fileNewname($path, $value['name'], true);
157
                    move_uploaded_file($value['tmp_name'], $path . $value['name']);
158
                    $image = $this->getServiceManager()->get('playgroundcore_image_service');
159
                    $image->setImage($path . $value['name']);
160
161
                    if ($image->canCorrectOrientation()) {
162
                        $image->correctOrientation()->save();
163
                    }
164
                    $postElement->setValue($media_url . $value['name']);
165
                    
166
                    if (class_exists("Imagick")) {
167
                        $ext = pathinfo($value['name'], PATHINFO_EXTENSION);
168
                        $img = new \Imagick($path . $value['name']);
169
                        $img->cropThumbnailImage(100, 100);
170
                        $img->setImageCompression(\Imagick::COMPRESSION_JPEG);
171
                        $img->setImageCompressionQuality(75);
172
                        // Strip out unneeded meta data
173
                        $img->stripImage();
174
                        $img->writeImage($path . str_replace('.'.$ext, '-thumbnail.'.$ext, $value['name']));
175
                        ErrorHandler::stop(true);
176
                    }
177
                }
178
            } elseif (is_array($value) || $form->get($name) instanceof \Zend\Form\Element\Select) {
179
                $arValues = $form->get($name)->getValueOptions();
180
                $postElement->setValue($arValues[$value[0]]);
181
            } elseif (!empty($value)) {
182
                $postElement->setValue($value);
183
            }
184
            $postElement->setPost($post);
185
            $postVotePostElementMapper->insert($postElement);
186
            $position++;
187
        }
188
189
        $postvotePostMapper->update($post);
190
191
        // If a preview step is not proposed, I confirmPost on this step
192
        $steps = $game->getStepsArray();
193
        $previewKey = array_search('preview', $steps);
194
        if (!$previewKey) {
195
            $post = $this->confirmPost($game, $user);
196
        }
197
198
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
199
            'user' => $user,
200
            'game' => $game,
201
            'post' => $post,
202
            'entry' => $entry
203
        ));
204
205
        return $post;
206
    }
207
208
    /**
209
     *
210
     * @return \PlaygroundGame\Entity\Game
211
     */
212
    public function confirmPost($game, $user)
213
    {
214
        $postvotePostMapper = $this->getPostVotePostMapper();
215
216
        $entryMapper = $this->getEntryMapper();
217
        $entry = $this->findLastActiveEntry($game, $user);
218
219
        if (!$entry) {
220
            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...
221
        }
222
223
        $post = $postvotePostMapper->findOneBy(array('entry' => $entry));
224
225
        if (! $post) {
226
            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...
227
        }
228
229
        // The post is confirmed by user. I update the status and close the associated entry
230
        // Post are validated by default, unless pre-moderation is enable for the game
231
        if ($game->getModerationType()) {
232
            $post->setStatus(1);
233
        } else {
234
            $post->setStatus(2);
235
        }
236
237
        $postvotePostMapper->update($post);
238
239
        $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...
240
        $entryMapper->update($entry);
241
242
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
243
            'user' => $user,
244
            'game' => $game,
245
            'entry' => $entry,
246
            'post' => $post
247
        ));
248
249
        if ($user) {
250
            // send mail for participation
251
            $this->sendGameMail($game, $user, $post, 'postvote');
252
        }
253
254
        return $post;
255
    }
256
257
    /**
258
     *
259
     * This service is ready for all types of games
260
     *
261
     * @param  array                  $data
262
     * @return \PlaygroundGame\Entity\Game
263
     */
264 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...
265
    {
266
        $title ='';
267
        $description = '';
268
269
        if ($data['form_jsonified']) {
270
            $jsonPV = json_decode($data['form_jsonified']);
271
            foreach ($jsonPV as $element) {
272
                if ($element->form_properties) {
273
                    $attributes  = $element->form_properties[0];
274
                    $title       = $attributes->title;
275
                    $description = $attributes->description;
276
277
                    break;
278
                }
279
            }
280
        }
281
        if (!$form) {
282
            $form = new \PlaygroundGame\Entity\PostVoteForm();
283
        }
284
        $form->setPostvote($game);
285
        $form->setTitle($title);
286
        $form->setDescription($description);
287
        $form->setForm($data['form_jsonified']);
288
        $form->setFormTemplate($data['form_template']);
289
290
        $form = $this->getPostVoteFormMapper()->insert($form);
291
292
        return $form;
293
    }
294
295
    public function findArrayOfValidatedPosts($game, $filter, $search = '')
296
    {
297
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
298
        $qb = $em->createQueryBuilder();
299
        $and = $qb->expr()->andx();
300
        
301
        $and->add($qb->expr()->eq('p.status', 2));
302
303
        $and->add($qb->expr()->eq('g.id', ':game'));
304
        $qb->setParameter('game', $game);
305
        
306
        if ($search != '') {
307
            $and->add(
308
                $qb->expr()->orX(
309
                    $qb->expr()->like('u.username', $qb->expr()->literal('%:search%')),
310
                    $qb->expr()->like('u.firstname', $qb->expr()->literal('%:search%')),
311
                    $qb->expr()->like('u.lastname', $qb->expr()->literal('%:search%')),
312
                    $qb->expr()->like('e.value', $qb->expr()->literal('%:search%')),
313
                    $qb->expr()->isNull('g.publicationDate')
314
                )
315
            );
316
            $qb->setParameter('search', $search);
317
        }
318
        
319
        if ('push' == $filter) {
320
            $and->add(
321
                $qb->expr()->andX(
322
                    $qb->expr()->eq('p.pushed', 1)
323
                )
324
            );
325
        }
326
        
327
        $qb->select('p, COUNT(v) AS votesCount')
328
            ->from('PlaygroundGame\Entity\PostVotePost', 'p')
329
            ->innerJoin('p.postvote', 'g')
330
            ->leftJoin('p.user', 'u')
331
            ->innerJoin('p.postElements', 'e')
332
            ->leftJoin('p.votes', 'v')
333
            ->where($and)
334
            ->groupBy('p.id');
335
 
336
        switch ($filter) {
337
            case 'random':
338
                $qb->orderBy('e.value', 'ASC');
339
                break;
340
            case 'vote':
341
                $qb->orderBy('votesCount', 'DESC');
342
                break;
343
            case 'date':
344
                $qb->orderBy('p.createdAt', 'DESC');
345
                break;
346
            case 'push':
347
                $qb->orderBy('p.createdAt', 'DESC');
348
                break;
349
        }
350
        
351
        $query = $qb->getQuery();
352
        
353
        $posts = $query->getResult();
354
        $arrayPosts = array();
355
        $i=0;
356
        foreach ($posts as $postRaw) {
357
            $data = array();
358
            $post = $postRaw[0];
359
            if ($post) {
360
                foreach ($post->getPostElements() as $element) {
361
                    $data[$element->getPosition()] = $element->getValue();
362
                }
363
                $arrayPosts[$i]['post']  = $post;
364
                $arrayPosts[$i]['data']  = $data;
365
                $arrayPosts[$i]['votes'] = count($post->getVotes());
366
                $arrayPosts[$i]['id']    = $post->getId();
367
                $arrayPosts[$i]['user']  = $post->getUser();
368
                $arrayPosts[$i]['createdAt']  = $post->getCreatedAt();
369
                $i++;
370
            }
371
        }
372
373
        return $arrayPosts;
374
    }
375
376
    public function addVote($user, $ipAddress, $post)
377
    {
378
        $postvoteVoteMapper = $this->getPostVoteVoteMapper();
379
        $postId = $post->getId();
380
381
        if ($user) {
382
            $userId = $user->getId();
383
            $entryUser = count($postvoteVoteMapper->findBy(array('userId' => $userId, 'post' =>$postId)));
384
        } else {
385
            $entryUser =count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' =>$postId)));
386
        }
387
        if ($entryUser && $entryUser > 0) {
388
            return false;
389
        } else {
390
            $vote = new \PlaygroundGame\Entity\PostVoteVote();
391
            $vote->setPost($post);
392
            $vote->setIp($ipAddress);
393
            if ($user) {
394
                $vote->setUserId($user->getId());
395
            }
396
397
            $postvoteVoteMapper->insert($vote);
398
            $game = $post->getPostvote();
399
            $this->getEventManager()->trigger(
400
                'vote_postvote.post',
401
                $this,
402
                array('user' => $user, 'game' => $game, 'post' => $post, 'vote' => $vote)
403
            );
404
405
            return true;
406
        }
407
    }
408
409
    public function addComment($user, $ipAddress, $post, $message = '')
410
    {
411
        $postvoteCommentMapper = $this->getPostVoteCommentMapper();
412
        $postId = $post->getId();
0 ignored issues
show
Unused Code introduced by
$postId 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...
413
        $comment = new \PlaygroundGame\Entity\PostVoteComment();
414
        $comment->setPost($post);
415
        $comment->setIp($ipAddress);
416
        $comment->setMessage($message);
0 ignored issues
show
Documentation introduced by
$message is of type string, but the function expects a object<PlaygroundGame\Entity\unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
417
        if ($user) {
418
            $comment->setUserId($user->getId());
419
        }
420
421
        $postvoteCommentMapper->insert($comment);
422
        $game = $post->getPostvote();
423
        $this->getEventManager()->trigger(
424
            'vote_postvote.post',
425
            $this,
426
            array('user' => $user, 'game' => $game, 'post' => $post, 'comment' => $comment)
427
        );
428
429
        return true;
430
    }
431
432
    public function getEntriesHeader($game)
433
    {
434
        $header = parent::getEntriesHeader($game);
435
        if ($game->getForm()) {
436
            $form = json_decode($game->getForm()->getForm(), true);
437 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...
438
                foreach ($element as $k => $v) {
439
                    if ($k !== 'form_properties') {
440
                        $header[$v[0]['name']] = 1;
441
                    }
442
                }
443
            }
444
        }
445
446
        return $header;
447
    }
448
449 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...
450
    {
451
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
452
453
        $qb = $em->createQueryBuilder();
454
        $qb->select('
455
            p.id,
456
            u.username,
457
            u.title,
458
            u.firstname,
459
            u.lastname,
460
            u.email,
461
            u.optin,
462
            u.optinPartner,
463
            u.address,
464
            u.address2,
465
            u.postalCode,
466
            u.city,
467
            u.telephone,
468
            u.mobile,
469
            u.created_at,
470
            u.dob,
471
            e.winner,
472
            e.socialShares,
473
            e.playerData,
474
            e.updated_at,
475
            p.status,
476
            p
477
            ')
478
            ->from('PlaygroundGame\Entity\PostVotePost', 'p')
479
            ->innerJoin('p.entry', 'e')
480
            ->leftJoin('p.user', 'u')
481
            ->where($qb->expr()->eq('e.game', ':game'));
482
        
483
        $qb->setParameter('game', $game);
484
485
        return $qb->getQuery();
486
    }
487
488
    /**
489
    * getGameEntries : All entries of a game
490
    *
491
    * @return Array of PlaygroundGame\Entity\Game
492
    */
493
    public function getGameEntries($header, $entries, $game)
494
    {
495
        $results = array();
496
497
        foreach ($entries as $k => $entry) {
498
            $entryData = json_decode($entry['playerData'], true);
499
            $postElements = $entry[0]->getPostElements();
500
501
            foreach ($header as $key => $v) {
502
                if (isset($entryData[$key]) && $key !=='id') {
503
                    $results[$k][$key] = (is_array($entryData[$key]))?implode(', ', $entryData[$key]):$entryData[$key];
504
                } elseif (array_key_exists($key, $entry)) {
505
                    $results[$k][$key] = ($entry[$key] instanceof \DateTime)?$entry[$key]->format('Y-m-d'):$entry[$key];
506
                } else {
507
                    $results[$k][$key] = '';
508
                }
509
510
                foreach ($postElements as $e) {
511
                    if ($key === $e->getName()) {
512
                        $results[$k][$key] = (is_array($e->getValue()))?implode(', ', $e->getValue()):$e->getValue();
513
                        break;
514
                    }
515
                }
516
            }
517
        }
518
519
        return $results;
520
    }
521
522
    public function getPostVoteFormMapper()
523
    {
524
        if (null === $this->postvoteformMapper) {
525
            $this->postvoteformMapper = $this->getServiceManager()->get('playgroundgame_postvoteform_mapper');
526
        }
527
528
        return $this->postvoteformMapper;
529
    }
530
531
    public function setPostVoteFormMapper($postvoteformMapper)
532
    {
533
        $this->postvoteformMapper = $postvoteformMapper;
534
535
        return $this;
536
    }
537
538
    public function getPostVotePostElementMapper()
539
    {
540
        if (null === $this->postVotePostElementMapper) {
541
            $this->postVotePostElementMapper = $this->getServiceManager()->get(
542
                'playgroundgame_postvotepostelement_mapper'
543
            );
544
        }
545
546
        return $this->postVotePostElementMapper;
547
    }
548
549
    public function setPostVotePostElementMapper($postVotePostElementMapper)
550
    {
551
        $this->postVotePostElementMapper = $postVotePostElementMapper;
552
553
        return $this;
554
    }
555
556
    public function getPostVoteVoteMapper()
557
    {
558
        if (null === $this->postVoteVoteMapper) {
559
            $this->postVoteVoteMapper = $this->getServiceManager()->get('playgroundgame_postvotevote_mapper');
560
        }
561
562
        return $this->postVoteVoteMapper;
563
    }
564
565
    public function setPostVoteVoteMapper($postVoteVoteMapper)
566
    {
567
        $this->postVoteVoteMapper = $postVoteVoteMapper;
568
569
        return $this;
570
    }
571
572
    public function getPostVoteCommentMapper()
573
    {
574
        if (null === $this->postVoteCommentMapper) {
575
            $this->postVoteCommentMapper = $this->getServiceManager()->get('playgroundgame_postvotecomment_mapper');
576
        }
577
578
        return $this->postVoteCommentMapper;
579
    }
580
581
    public function setPostVoteCommentMapper($postVoteCommentMapper)
582
    {
583
        $this->postVoteCommentMapper = $postVoteCommentMapper;
584
585
        return $this;
586
    }
587
588
    public function getPostVotePostMapper()
589
    {
590
        if (null === $this->postVotePostMapper) {
591
            $this->postVotePostMapper = $this->getServiceManager()->get('playgroundgame_postvotepost_mapper');
592
        }
593
594
        return $this->postVotePostMapper;
595
    }
596
597
    public function setPostVotePostMapper($postVotePostMapper)
598
    {
599
        $this->postVotePostMapper = $postVotePostMapper;
600
601
        return $this;
602
    }
603
604
    public function getPostVoteMapper()
605
    {
606
        if (null === $this->postvoteMapper) {
607
            $this->postvoteMapper = $this->getServiceManager()->get('playgroundgame_postvote_mapper');
608
        }
609
610
        return $this->postvoteMapper;
611
    }
612
613
    /**
614
     * setQuizQuestionMapper
615
     *
616
     * @return PostVote
617
     */
618
    public function setPostVoteMapper($postvoteMapper)
619
    {
620
        $this->postvoteMapper = $postvoteMapper;
621
622
        return $this;
623
    }
624
}
625