Code Duplication    Length = 41-42 lines in 2 locations

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

@@ 581-621 (lines=41) @@
578
        return $viewModel;
579
    }
580
581
    public function ajaxVoteAction()
582
    {
583
        // Call this for the session lock to be released (other ajax calls can then be made)
584
        session_write_close();
585
        $postId = $this->getEvent()->getRouteMatch()->getParam('post');
586
        $request = $this->getRequest();
587
        $response = $this->getResponse();
588
589
        if (! $this->game) {
590
            $response->setContent(\Zend\Json\Json::encode(array(
591
                'success' => 0
592
            )));
593
594
            return $response;
595
        }
596
597
        if (!$this->zfcUserAuthentication()->hasIdentity()) {
598
            $response->setContent(\Zend\Json\Json::encode(array(
599
                'success' => 0
600
            )));
601
        } else {
602
            if ($request->isPost()) {
603
                $post = $this->getGameService()->getPostvotePostMapper()->findById($postId);
604
                if ($this->getGameService()->addVote(
605
                    $this->user,
606
                    $this->getRequest()->getServer('REMOTE_ADDR'),
607
                    $post
608
                )) {
609
                    $response->setContent(\Zend\Json\Json::encode(array(
610
                        'success' => 1
611
                    )));
612
                } else {
613
                    $response->setContent(\Zend\Json\Json::encode(array(
614
                        'success' => 0
615
                    )));
616
                }
617
            }
618
        }
619
620
        return $response;
621
    }
622
623
    public function commentsAction()
624
    {
@@ 648-689 (lines=42) @@
645
        return $viewModel;
646
    }
647
648
    public function ajaxCommentAction()
649
    {
650
        // Call this for the session lock to be released (other ajax calls can then be made)
651
        session_write_close();
652
        $postId = $this->getEvent()->getRouteMatch()->getParam('post');
653
        $request = $this->getRequest();
654
        $response = $this->getResponse();
655
656
        if (! $this->game) {
657
            $response->setContent(\Zend\Json\Json::encode(array(
658
                'success' => 0
659
            )));
660
661
            return $response;
662
        }
663
664
        if (!$this->zfcUserAuthentication()->hasIdentity()) {
665
            $response->setContent(\Zend\Json\Json::encode(array(
666
                'success' => 0
667
            )));
668
        } else {
669
            if ($request->isPost()) {
670
                $post = $this->getGameService()->getPostvotePostMapper()->findById($postId);
671
                if ($this->getGameService()->addComment(
672
                    $this->user,
673
                    $this->getRequest()->getServer('REMOTE_ADDR'),
674
                    $post,
675
                    $this->params()->fromPost('comment')
676
                )) {
677
                    $response->setContent(\Zend\Json\Json::encode(array(
678
                        'success' => 1
679
                    )));
680
                } else {
681
                    $response->setContent(\Zend\Json\Json::encode(array(
682
                        'success' => 0
683
                    )));
684
                }
685
            }
686
        }
687
688
        return $response;
689
    }
690
691
    public function ajaxRemoveCommentAction()
692
    {