Code Duplication    Length = 12-17 lines in 10 locations

src/PlaygroundGame/Controller/Frontend/GameController.php 1 location

@@ 460-476 (lines=17) @@
457
            );
458
        }
459
    
460
        if (!$user && !$this->game->getAnonymousAllowed()) {
461
            $redirect = urlencode(
462
                $this->frontendUrl()->fromRoute(
463
                    'postvote/result',
464
                    array(
465
                        'id' => $this->game->getIdentifier(),
466
                        
467
                    )
468
                )
469
            );
470
            return $this->redirect()->toUrl(
471
                $this->frontendUrl()->fromRoute(
472
                    'zfcuser/register',
473
                    array()
474
                ) . '?redirect='.$redirect
475
            );
476
        }
477
    
478
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
479
        $form->setAttribute('method', 'post');

src/PlaygroundGame/Controller/Frontend/InstantWinController.php 2 locations

@@ 21-36 (lines=16) @@
18
19
        $user = $this->zfcUserAuthentication()->getIdentity();
20
21
        if (!$user && !$this->game->getAnonymousAllowed()) {
22
            $redirect = urlencode(
23
                $this->frontendUrl()->fromRoute(
24
                    $this->game->getClassType() . '/play',
25
                    array('id' => $this->game->getIdentifier()),
26
                    array('force_canonical' => true)
27
                )
28
            );
29
30
            return $this->redirect()->toUrl(
31
                $this->frontendUrl()->fromRoute(
32
                    'zfcuser/register',
33
                    array()
34
                ) . '?redirect='.$redirect
35
            );
36
        }
37
38
        if ($this->game->getOccurrenceType()=='datetime') {
39
            $entry = $this->getGameService()->play($this->game, $user);
@@ 131-144 (lines=14) @@
128
            $occurrence = current($occurrences);
129
        }
130
131
        if (!$user && !$this->game->getAnonymousAllowed()) {
132
            $redirect = urlencode(
133
                $this->frontendUrl()->fromRoute(
134
                    'instantwin/result',
135
                    array('id' => $this->game->getIdentifier(), )
136
                )
137
            );
138
            return $this->redirect()->toUrl(
139
                $this->frontendUrl()->fromRoute(
140
                    'zfcuser/register',
141
                    array()
142
                ) . '?redirect='.$redirect
143
            );
144
        }
145
146
        $secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15));
147
        $socialLinkUrl = $this->frontendUrl()->fromRoute(

src/PlaygroundGame/Controller/Frontend/LotteryController.php 2 locations

@@ 20-35 (lines=16) @@
17
        }
18
19
        $user = $this->zfcUserAuthentication()->getIdentity();
20
        if (!$user && !$this->game->getAnonymousAllowed()) {
21
            $redirect = urlencode(
22
                $this->frontendUrl()->fromRoute(
23
                    $this->game->getClassType() . '/play',
24
                    array('id' => $this->game->getIdentifier(), ),
25
                    array('force_canonical' => true)
26
                )
27
            );
28
29
            return $this->redirect()->toUrl(
30
                $this->frontendUrl()->fromRoute(
31
                    'zfcuser/register',
32
                    array()
33
                ) . '?redirect='.$redirect
34
            );
35
        }
36
37
        $entry = $this->getGameService()->play($this->game, $user);
38
        if (!$entry) {
@@ 87-103 (lines=17) @@
84
            );
85
        }
86
87
        if (!$user && !$this->game->getAnonymousAllowed()) {
88
            $redirect = urlencode(
89
                $this->frontendUrl()->fromRoute(
90
                    'lottery/result',
91
                    array(
92
                        'id' => $this->game->getIdentifier(),
93
                        
94
                    )
95
                )
96
            );
97
            return $this->redirect()->toUrl(
98
                $this->frontendUrl()->fromRoute(
99
                    'zfcuser/register',
100
                    array()
101
                ) . '?redirect='.$redirect
102
            );
103
        }
104
105
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
106
        $form->setAttribute('method', 'post');

src/PlaygroundGame/Controller/Frontend/PostVoteController.php 4 locations

@@ 32-47 (lines=16) @@
29
30
        $user = $this->zfcUserAuthentication()->getIdentity();
31
32
        if (!$user && !$this->game->getAnonymousAllowed()) {
33
            $redirect = urlencode(
34
                $this->frontendUrl()->fromRoute(
35
                    $this->game->getClassType() . '/play',
36
                    array('id' => $this->game->getIdentifier()),
37
                    array('force_canonical' => true)
38
                )
39
            );
40
41
            return $this->redirect()->toUrl(
42
                $this->frontendUrl()->fromRoute(
43
                    'zfcuser/register',
44
                    array()
45
                ) . '?redirect='.$redirect
46
            );
47
        }
48
49
        $entry = $this->getGameService()->play($this->game, $user);
50
@@ 150-161 (lines=12) @@
147
                $data = $form->getData();
148
                $post = $this->getGameService()->createPost($data, $this->game, $user, $form);
149
150
                if ($post && !empty($this->game->nextStep('play'))) {
151
                    // determine the route where the user should go
152
                    $redirectUrl = $this->frontendUrl()->fromRoute(
153
                        'postvote/'.$this->game->nextStep('play'),
154
                        array(
155
                            'id' => $this->game->getIdentifier(),
156
                            
157
                        )
158
                    );
159
160
                    return $this->redirect()->toUrl($redirectUrl);
161
                }
162
            } else {
163
                $messages = $form->getMessages();
164
                $viewModel = $this->buildView($this->game);
@@ 353-369 (lines=17) @@
350
        $statusMail = null;
351
        
352
        $user = $this->zfcUserAuthentication()->getIdentity();
353
        if (!$user && !$this->game->getAnonymousAllowed()) {
354
            $redirect = urlencode(
355
                $this->frontendUrl()->fromRoute(
356
                    'postvote/result',
357
                    array(
358
                        'id' => $this->game->getIdentifier(),
359
                        
360
                    )
361
                )
362
            );
363
            return $this->redirect()->toUrl(
364
                $this->frontendUrl()->fromRoute(
365
                    'zfcuser/register',
366
                    array()
367
                ) . '?redirect='.$redirect
368
            );
369
        }
370
371
        // Has the user finished the game ?
372
        $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $user);
@@ 700-713 (lines=14) @@
697
    {
698
        $statusMail = null;
699
        $user = $this->zfcUserAuthentication()->getIdentity();
700
        if (!$user && !$this->game->getAnonymousAllowed()) {
701
            $redirect = urlencode(
702
                $this->frontendUrl()->fromRoute(
703
                    'postvote/result',
704
                    array('id' => $this->game->getIdentifier())
705
                )
706
            );
707
            return $this->redirect()->toUrl(
708
                $this->frontendUrl()->fromRoute(
709
                    'zfcuser/register',
710
                    array()
711
                ) . '?redirect='.$redirect
712
            );
713
        }
714
    
715
        // Has the user finished the game ?
716
        $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $user);

src/PlaygroundGame/Controller/Frontend/QuizController.php 1 location

@@ 26-41 (lines=16) @@
23
24
        $user = $this->zfcUserAuthentication()->getIdentity();
25
26
        if (!$user && !$this->game->getAnonymousAllowed()) {
27
            $redirect = urlencode(
28
                $this->frontendUrl()->fromRoute(
29
                    $this->game->getClassType() . '/play',
30
                    array('id' => $this->game->getIdentifier()),
31
                    array('force_canonical' => true)
32
                )
33
            );
34
35
            return $this->redirect()->toUrl(
36
                $this->frontendUrl()->fromRoute(
37
                    'zfcuser/register',
38
                    array()
39
                ) . '?redirect='.$redirect
40
            );
41
        }
42
43
        $entry = $this->getGameService()->play($this->game, $user);
44
        if (!$entry) {