Code Duplication    Length = 23-24 lines in 2 locations

Controller/DashboardController.php 2 locations

@@ 48-70 (lines=23) @@
45
     *
46
     * @return RedirectResponse|Response
47
     */
48
    public function addAction(Request $request)
49
    {
50
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
51
        $cron = new Cron();
52
        $this->addFlash('message', $cronManager->getOutput());
53
        $this->addFlash('error', $cronManager->getError());
54
        $form = $this->createForm(new CronType(), $cron);
55
56
        $form->handleRequest($request);
57
        if ($form->isValid()) {
58
            $cronManager->add($cron);
59
            $this->addFlash('message', $cronManager->getOutput());
60
            $this->addFlash('error', $cronManager->getError());
61
62
            return $this->redirect($this->generateUrl('foa_cron_index'));
63
        }
64
65
        return $this->render('FOACronBundle:Dashboard:index.html.twig', [
66
            'crons' => $cronManager->getCrons(),
67
            'raw'   => $cronManager->getRaw(),
68
            'form'  => $form->createView(),
69
        ]);
70
    }
71
72
    /**
73
     * Edit a cron
@@ 79-102 (lines=24) @@
76
     *
77
     * @return RedirectResponse|Response
78
     */
79
    public function editAction($id)
80
    {
81
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
82
        $this->addFlash('message', $cronManager->getOutput());
83
        $this->addFlash('error', $cronManager->getError());
84
        $cron = $cronManager->getById($id);
85
        $form = $this->createForm(new CronType(), $cron);
86
87
        $request = $this->get('request');
88
        $form->handleRequest($request);
89
        if ($form->isValid()) {
90
            $cronManager->write();
91
92
            $this->addFlash('message', $cronManager->getOutput());
93
            $this->addFlash('error', $cronManager->getError());
94
95
            return $this->redirect($this->generateUrl('foa_cron_index'));
96
        }
97
98
        return $this->render('FOACronBundle:Dashboard:edit.html.twig', [
99
            'id'   => $id,
100
            'form' => $form->createView(),
101
        ]);
102
    }
103
104
    /**
105
     * Wake up a cron from the cron table