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

@@ 350-367 (lines=18) @@
347
                $user = $view->user;
348
349
                // If the user can not be created/retrieved from Facebook info, redirect to login/register form
350
                if (!$user) {
351
                    $redirectUrl = urlencode(
352
                        $this->frontendUrl()->fromRoute(
353
                            $game->getClassType() .'/play', 
354
                            array(
355
                                'id' => $game->getIdentifier(), 
356
                                'channel' => $channel
357
                            ), 
358
                            array('force_canonical' => true)
359
                        )
360
                    );
361
                    $redirect =  $this->redirect()->toUrl(
362
                        $this->frontendUrl()->fromRoute(
363
                            'zfcuser/register', 
364
                            array('channel' => $channel)
365
                        ) . '?redirect='.$redirectUrl
366
                    );
367
                }
368
            }
369
370
            if ($game->getFbFan()) {
@@ 729-732 (lines=4) @@
726
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
727
        }
728
    
729
        if (!$user && !$game->getAnonymousAllowed()) {
730
            $redirect = urlencode($this->frontendUrl()->fromRoute('postvote/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));
731
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('zfcuser/register', array('channel' => $channel)) . '?redirect='.$redirect);
732
        }
733
    
734
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
735
        $form->setAttribute('method', 'post');