Code Duplication    Length = 8-11 lines in 8 locations

src/Controller/Frontend/MissionController.php 1 location

@@ 49-59 (lines=11) @@
46
    {
47
        $subGameIdentifier = $this->getEvent()->getRouteMatch()->getParam('gameId');
48
        $entry             = $this->getGameService()->play($this->game, $this->user);
49
        if (!$entry) {
50
          // the user has already taken part of this game and the participation limit has been reached
51
            $this->flashMessenger()->addMessage('You have already played');
52
53
            return $this->redirect()->toUrl(
54
                $this->frontendUrl()->fromRoute(
55
                    'mission/result',
56
                    array('id' => $this->game->getIdentifier())
57
                )
58
            );
59
        }
60
61
        if (!$subGameIdentifier) {
62
            $subGame = $this->game->getNextPlayableGame($entry);

src/Controller/Frontend/QuizController.php 1 location

@@ 214-222 (lines=9) @@
211
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
212
213
        $lastEntry = $this->getGameService()->findLastEntry($this->game, $this->user);
214
        if (!$lastEntry) {
215
            return $this->redirect()->toUrl(
216
                $this->frontendUrl()->fromRoute(
217
                    'quiz',
218
                    array('id' => $this->game->getIdentifier()),
219
                    array('force_canonical' => true)
220
                )
221
            );
222
        }
223
224
        // je compte les bonnes réponses et le ratio
225
        $maxCorrectAnswers = $this->game->getMaxCorrectAnswers();

src/Controller/Frontend/InstantWinController.php 2 locations

@@ 22-32 (lines=11) @@
19
    {
20
        if ($this->game->getOccurrenceType()=='datetime') {
21
            $entry = $this->getGameService()->play($this->game, $this->user);
22
            if (!$entry) {
23
                // the user has already taken part of this game and the participation limit has been reached
24
                $this->flashMessenger()->addMessage('Vous avez déjà participé');
25
26
                return $this->redirect()->toUrl(
27
                    $this->frontendUrl()->fromRoute(
28
                        'instantwin/result',
29
                        array('id' => $this->game->getIdentifier())
30
                    )
31
                );
32
            }
33
34
            // update the winner attribute in entry.
35
            $occurrence = $this->getGameService()->IsInstantWinner($this->game, $this->user);
@@ 92-100 (lines=9) @@
89
    {
90
        $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
91
92
        if (!$lastEntry) {
93
            return $this->redirect()->toUrl(
94
                $this->frontendUrl()->fromRoute(
95
                    'instantwin',
96
                    array('id' => $this->game->getIdentifier(), ),
97
                    array('force_canonical' => true)
98
                )
99
            );
100
        }
101
        $winner = $lastEntry->getWinner();
102
        $occurrence = null;
103

src/Controller/Frontend/LotteryController.php 2 locations

@@ 21-31 (lines=11) @@
18
    public function playAction()
19
    {
20
        $entry = $this->getGameService()->play($this->game, $this->user);
21
        if (!$entry) {
22
            // the user has already taken part of this game and the participation limit has been reached
23
            $this->flashMessenger()->addMessage('Vous avez déjà participé');
24
25
            return $this->redirect()->toUrl(
26
                $this->frontendUrl()->fromRoute(
27
                    'lottery/result',
28
                    array('id' => $this->game->getIdentifier())
29
                )
30
            );
31
        }
32
33
        // Every entry is eligible to draw
34
        $entry->setDrawable(true);
@@ 59-67 (lines=9) @@
56
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
57
58
        $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
59
        if (!$lastEntry) {
60
            return $this->redirect()->toUrl(
61
                $this->frontendUrl()->fromRoute(
62
                    'lottery',
63
                    array('id' => $this->game->getIdentifier()),
64
                    array('force_canonical' => true)
65
                )
66
            );
67
        }
68
69
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
70
        $form->setAttribute('method', 'post');

src/Controller/Frontend/PostVoteController.php 2 locations

@@ 157-165 (lines=9) @@
154
    {
155
        $entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user);
156
         
157
        if (!$entry) {
158
            // the user has already taken part of this game and the participation limit has been reached
159
            return $this->redirect()->toUrl(
160
                $this->frontendUrl()->fromRoute(
161
                    'postvote/'.$this->game->nextStep('preview'),
162
                    array('id' => $this->game->getIdentifier())
163
                )
164
            );
165
        }
166
167
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
168
        $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0));
@@ 229-236 (lines=8) @@
226
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
227
        $post = $this->getGameService()->getPostVotePostMapper()->findById($postId);
228
229
        if (! $post || $post->getStatus() === 9) {
230
            return $this->redirect()->toUrl(
231
                $this->frontendUrl()->fromRoute(
232
                    'postvote',
233
                    array('id' => $this->game->getIdentifier())
234
                )
235
            );
236
        }
237
238
        $formModeration = new Form();
239
        $formModeration->setAttribute('method', 'post');