Code Duplication    Length = 38-38 lines in 2 locations

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

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

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
    {