Code Duplication    Length = 16-18 lines in 5 locations

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

@@ 255-270 (lines=16) @@
252
253
        $form->bind($occurrence);
254
255
        if ($this->getRequest()->isPost()) {
256
            $data = array_merge(
257
                $this->getRequest()->getPost()->toArray(),
258
                $this->getRequest()->getFiles()->toArray()
259
            );
260
            $occurrence = $service->updateOccurrence($data, $occurrence->getId());
261
262
            if ($occurrence) {
263
                // Redirect to list of games
264
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The occurrence was edited');
265
                return $this->redirect()->toRoute(
266
                    'admin/playgroundgame/instantwin-occurrence-list',
267
                    array('gameId'=>$this->game->getId())
268
                );
269
            }
270
        }
271
        return $viewModel->setVariables(
272
            array(
273
                'form' => $form,

src/PlaygroundGame/Controller/Admin/QuizController.php 2 locations

@@ 71-88 (lines=18) @@
68
        $question = new QuizQuestion();
69
        $form->bind($question);
70
71
        if ($this->getRequest()->isPost()) {
72
            $data = array_replace_recursive(
73
                $this->getRequest()->getPost()->toArray(),
74
                $this->getRequest()->getFiles()->toArray()
75
            );
76
77
            $question = $service->createQuestion($data);
78
            if ($question) {
79
                // Redirect to list of games
80
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was created');
81
82
                return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId));
83
            } else { // Creation failed
84
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage(
85
                    'The question was not updated - create at least one good answer'
86
                );
87
            }
88
        }
89
90
        return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => 0));
91
    }
@@ 117-134 (lines=18) @@
114
115
        $form->bind($question);
116
117
        if ($this->getRequest()->isPost()) {
118
            $data = array_replace_recursive(
119
                $this->getRequest()->getPost()->toArray(),
120
                $this->getRequest()->getFiles()->toArray()
121
            );
122
123
            $question = $service->updateQuestion($data, $question);
124
            if ($question) {
125
                // Redirect to list of games
126
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was updated');
127
128
                return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId));
129
            } else {
130
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage(
131
                    'The question was not updated - create at least one good answer'
132
                );
133
            }
134
        }
135
136
        return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => $questionId));
137
    }

src/PlaygroundGame/Controller/Admin/TradingCardController.php 2 locations

@@ 124-139 (lines=16) @@
121
        $model = new TradingCardModel();
122
        $form->bind($model);
123
124
        if ($this->getRequest()->isPost()) {
125
            $data = array_merge(
126
                $this->getRequest()->getPost()->toArray(),
127
                $this->getRequest()->getFiles()->toArray()
128
            );
129
130
            $model = $this->getAdminGameService()->updateModel($data, $model);
131
            if ($model) {
132
                // Redirect to list of games
133
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The model has been created');
134
                return $this->redirect()->toRoute(
135
                    'admin/playgroundgame/tradingcard-model-list',
136
                    array('gameId' => $this->game->getId())
137
                );
138
            }
139
        }
140
        return $viewModel->setVariables(
141
            array(
142
                'form'     => $form,
@@ 171-186 (lines=16) @@
168
169
        $form->bind($model);
170
171
        if ($this->getRequest()->isPost()) {
172
            $data = array_merge(
173
                $this->getRequest()->getPost()->toArray(),
174
                $this->getRequest()->getFiles()->toArray()
175
            );
176
            $model = $service->updateModel($data, $model);
177
178
            if ($model) {
179
                // Redirect to list of games
180
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The model has been edited');
181
                return $this->redirect()->toRoute(
182
                    'admin/playgroundgame/tradingcard-model-list',
183
                    array('gameId' => $this->game->getId())
184
                );
185
            }
186
        }
187
        return $viewModel->setVariables(
188
            array(
189
                'form'     => $form,