Code Duplication    Length = 38-38 lines in 2 locations

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

@@ 16-53 (lines=38) @@
13
     */
14
    protected $adminGameService;
15
16
    public function formAction()
17
    {
18
        $service = $this->getAdminGameService();
19
        $gameId = $this->getEvent()->getRouteMatch()->getParam('gameId');
20
        if (!$gameId) {
21
            return $this->redirect()->toRoute('admin/playgroundgame/list');
22
        }
23
        $game = $service->getGameMapper()->findById($gameId);
24
        $form = $service->getPostVoteFormMapper()->findByGame($game);
25
26
        // I use the wonderful Form Generator to create the Post & Vote form
27
        $this->forward()->dispatch(
28
            'PlaygroundCore\Controller\Formgen',
29
            array(
30
                'controller' => 'PlaygroundCore\Controller\Formgen',
31
                'action' => 'create'
32
            )
33
        );
34
35
        if ($this->getRequest()->isPost()) {
36
            $data = $this->getRequest()->getPost()->toArray();
37
            $form = $service->createForm($data, $game, $form);
38
            if ($form) {
39
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The form was created');
40
            }
41
        }
42
        $formTemplate='';
43
        if ($form) {
44
            $formTemplate = $form->getFormTemplate();
45
        }
46
47
        return array(
48
            'form' => $form,
49
            'formTemplate' => $formTemplate,
50
            'gameId' => $gameId,
51
            'game' => $game,
52
        );
53
    }
54
55
    public function createPostVoteAction()
56
    {

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

@@ 251-288 (lines=38) @@
248
        return $this->redirect()->toRoute('admin/playgroundgame/list');
249
    }
250
251
    public function formAction()
252
    {
253
        $service = $this->getAdminGameService();
254
        $gameId = $this->getEvent()->getRouteMatch()->getParam('gameId');
255
        if (!$gameId) {
256
            return $this->redirect()->toRoute('admin/playgroundgame/list');
257
        }
258
        $game = $service->getGameMapper()->findById($gameId);
259
        $form = $service->getPlayerFormMapper()->findOneBy(array('game' => $game));
260
261
        // I use the wonderful Form Generator to create the Post & Vote form
262
        $this->forward()->dispatch(
263
            'PlaygroundCore\Controller\Formgen',
264
            array(
265
                'controller' => 'PlaygroundCore\Controller\Formgen',
266
                'action' => 'create'
267
            )
268
        );
269
270
        if ($this->getRequest()->isPost()) {
271
            $data = $this->getRequest()->getPost()->toArray();
272
            $form = $service->createForm($data, $game, $form);
273
            if ($form) {
274
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The form was created');
275
            }
276
        }
277
        $formTemplate='';
278
        if ($form) {
279
            $formTemplate = $form->getFormTemplate();
280
        }
281
282
        return array(
283
            'form' => $form,
284
            'formTemplate' => $formTemplate,
285
            'gameId' => $gameId,
286
            'game' => $game,
287
        );
288
    }
289
290
    public function setOptions(ModuleOptions $options)
291
    {