Code Duplication    Length = 4-19 lines in 8 locations

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

@@ 31-49 (lines=19) @@
28
29
        $user = $this->zfcUserAuthentication()->getIdentity();
30
31
        if (!$user && !$game->getAnonymousAllowed()) {
32
            $redirect = urlencode(
33
                $this->frontendUrl()->fromRoute(
34
                    $game->getClassType() . '/play',
35
                    array(
36
                        'id' => $game->getIdentifier(),
37
                        'channel' => $channel
38
                    ),
39
                    array('force_canonical' => true)
40
                )
41
            );
42
43
            return $this->redirect()->toUrl(
44
                $this->frontendUrl()->fromRoute(
45
                    'zfcuser/register',
46
                    array('channel' => $channel)
47
                ) . '?redirect='.$redirect
48
            );
49
        }
50
51
        if ($game->getOccurrenceType()=='datetime') {
52
            if ($this->getRequest()->isPost()) {
@@ 193-196 (lines=4) @@
190
            $occurrence = current($occurrences);
191
        }
192
193
        if (!$user && !$game->getAnonymousAllowed()) {
194
            $redirect = urlencode($this->frontendUrl()->fromRoute('instantwin/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));
195
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('zfcuser/register', array('channel' => $channel)) . '?redirect='.$redirect);
196
        }
197
198
        $secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15));
199
        $socialLinkUrl = $this->frontendUrl()->fromRoute('instantwin', array('id' => $game->getIdentifier(), 'channel' => $channel), array('force_canonical' => true)).'?key='.$secretKey;

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

@@ 75-78 (lines=4) @@
72
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('lottery', array('id' => $game->getIdentifier(), 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel')), array('force_canonical' => true)));
73
        }
74
75
        if (!$user && !$game->getAnonymousAllowed()) {
76
            $redirect = urlencode($this->frontendUrl()->fromRoute('lottery/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));
77
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('zfcuser/register', array('channel' => $channel)) . '?redirect='.$redirect);
78
        }
79
80
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
81
        $form->setAttribute('method', 'post');

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

@@ 306-309 (lines=4) @@
303
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
304
        }
305
306
        if (!$user && !$game->getAnonymousAllowed()) {
307
            $redirect = urlencode($this->frontendUrl()->fromRoute('postvote/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));
308
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('zfcuser/register', array('channel' => $channel)) . '?redirect='.$redirect);
309
        }
310
311
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
312
        $form->setAttribute('method', 'post');
@@ 648-651 (lines=4) @@
645
        // With core shortener helper
646
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
647
    
648
        if (!$user && !$game->getAnonymousAllowed()) {
649
            $redirect = urlencode($this->frontendUrl()->fromRoute('postvote/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));
650
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('zfcuser/register', array('channel' => $channel)) . '?redirect='.$redirect);
651
        }
652
    
653
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
654
        $form->setAttribute('method', 'post');

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

@@ 36-40 (lines=5) @@
33
34
        $user       = $this->zfcUserAuthentication()->getIdentity();
35
36
        if (!$user && !$game->getAnonymousAllowed()) {
37
            $redirect = urlencode($this->frontendUrl()->fromRoute($game->getClassType() . '/play', array('id' => $game->getIdentifier(), 'channel' => $channel), array('force_canonical' => true)));
38
39
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('zfcuser/register', array('channel' => $channel)) . '?redirect='.$redirect);
40
        }
41
42
        $entry = $sg->play($game, $user);
43
        if (!$entry) {

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

@@ 393-410 (lines=18) @@
390
                $user = $view->user;
391
392
                // If the user can not be created/retrieved from Facebook info, redirect to login/register form
393
                if (!$user) {
394
                    $redirectUrl = urlencode(
395
                        $this->frontendUrl()->fromRoute(
396
                            $game->getClassType() .'/play',
397
                            array(
398
                                'id' => $game->getIdentifier(),
399
                                'channel' => $channel
400
                            ),
401
                            array('force_canonical' => true)
402
                        )
403
                    );
404
                    $redirect =  $this->redirect()->toUrl(
405
                        $this->frontendUrl()->fromRoute(
406
                            'zfcuser/register',
407
                            array('channel' => $channel)
408
                        ) . '?redirect='.$redirectUrl
409
                    );
410
                }
411
            }
412
413
            if ($game->getFbFan()) {
@@ 819-822 (lines=4) @@
816
            );
817
        }
818
    
819
        if (!$user && !$game->getAnonymousAllowed()) {
820
            $redirect = urlencode(
821
                $this->frontendUrl()->fromRoute(
822
                    'postvote/result',
823
                    array(
824
                        'id' => $game->getIdentifier(),
825
                        'channel' => $channel