Code Duplication    Length = 38-44 lines in 2 locations

src/PlaygroundGame/Controller/Admin/PostVoteController.php 1 location

@@ 55-98 (lines=44) @@
52
        );
53
    }
54
55
    public function createPostVoteAction()
56
    {
57
        $service = $this->getAdminGameService();
58
        $viewModel = new ViewModel();
59
        $viewModel->setTemplate('playground-game/post-vote/postvote');
60
61
        $gameForm = new ViewModel();
62
        $gameForm->setTemplate('playground-game/game/game-form');
63
64
        $postVote = new PostVote();
65
66
        $form = $this->getServiceLocator()->get('playgroundgame_postvote_form');
67
        $form->bind($postVote);
68
        $form->get('submit')->setAttribute('label', 'Add');
69
        $form->setAttribute(
70
            'action',
71
            $this->url()->fromRoute(
72
                'admin/playgroundgame/create-postvote',
73
                array('gameId' => 0)
74
            )
75
        );
76
        $form->setAttribute('method', 'post');
77
78
        $request = $this->getRequest();
79
        if ($request->isPost()) {
80
            $data = array_replace_recursive(
81
                $this->getRequest()->getPost()->toArray(),
82
                $this->getRequest()->getFiles()->toArray()
83
            );
84
            if (empty($data['prizes'])) {
85
                $data['prizes'] = array();
86
            }
87
            $game = $service->create($data, $postVote, 'playgroundgame_postvote_form');
88
            if ($game) {
89
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The game was created');
90
91
                return $this->redirect()->toRoute('admin/playgroundgame/list');
92
            }
93
        }
94
        $gameForm->setVariables(array('form' => $form, 'game' => $postVote));
95
        $viewModel->addChild($gameForm, 'game_form');
96
97
        return $viewModel->setVariables(array('form' => $form, 'title' => 'Create Post & Vote'));
98
    }
99
100
    public function editPostVoteAction()
101
    {

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

@@ 156-193 (lines=38) @@
153
        return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId));
154
    }
155
156
    public function createQuizAction()
157
    {
158
        $service = $this->getAdminGameService();
159
        $viewModel = new ViewModel();
160
        $viewModel->setTemplate('playground-game/quiz/quiz');
161
162
        $gameForm = new ViewModel();
163
        $gameForm->setTemplate('playground-game/game/game-form');
164
165
        $quiz = new Quiz();
166
167
        $form = $this->getServiceLocator()->get('playgroundgame_quiz_form');
168
        $form->bind($quiz);
169
        $form->get('submit')->setAttribute('label', 'Add');
170
        $form->setAttribute('action', $this->url()->fromRoute('admin/playgroundgame/create-quiz', array('gameId' => 0)));
171
        $form->setAttribute('method', 'post');
172
173
        $request = $this->getRequest();
174
        if ($request->isPost()) {
175
            $data = array_replace_recursive(
176
                $this->getRequest()->getPost()->toArray(),
177
                $this->getRequest()->getFiles()->toArray()
178
            );
179
            if (empty($data['prizes'])) {
180
                $data['prizes'] = array();
181
            }
182
            $game = $service->create($data, $quiz, 'playgroundgame_quiz_form');
183
            if ($game) {
184
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The game was created');
185
186
                return $this->redirect()->toRoute('admin/playgroundgame/list');
187
            }
188
        }
189
        $gameForm->setVariables(array('form' => $form, 'game' => $quiz));
190
        $viewModel->addChild($gameForm, 'game_form');
191
192
        return $viewModel->setVariables(array('form' => $form, 'title' => 'Create quiz'));
193
    }
194
195
    public function editQuizAction()
196
    {