Code Duplication    Length = 23-27 lines in 4 locations

src/AppBundle/Controller/Install/Install4Controller.php 4 locations

@@ 51-77 (lines=27) @@
48
     *
49
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
50
     */
51
    public function step41Action(Request $request)
52
    {
53
        $familylog = new FamilyLog();
54
        $form = $this->createForm(new FamilyLogType(), $familylog, array(
55
            'action' => $this->generateUrl('gs_install_st4_1')
56
        ));
57
58
        if ($form->handleRequest($request)->isValid()) {
59
            $em = $this->getDoctrine()->getManager();
60
            $em->persist($familylog);
61
            $em->flush();
62
63
            if ($form->get('save')->isSubmitted()) {
64
                $url = $this->redirect($this->generateUrl('gs_install_st4'));
65
            } elseif ($form->get('addmore')->isSubmitted()) {
66
                $url = $this->redirect($this->generateUrl('gs_install_st4_1'));
67
            }
68
            $this->addFlash('info', 'gestock.settings.add_ok');
69
70
            return $this->redirect($this->generateUrl('gs_install_st4_1'));
71
        }
72
73
        return array(
74
            'familylog' => $familylog,
75
            'form'   => $form->createView(),
76
        );
77
    }
78
79
    /**
80
     * Etape 4.2 de l'installation.
@@ 91-113 (lines=23) @@
88
     *
89
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
90
     */
91
    public function step42Action(Request $request)
92
    {
93
        $zoneStorage = new ZoneStorage();
94
        $form = $this->createForm(new ZoneStorageType(), $zoneStorage, array(
95
            'action' => $this->generateUrl('gs_install_st4_2')
96
        ));
97
98
        if ($form->handleRequest($request)->isValid()) {
99
            $em = $this->getDoctrine()->getManager();
100
            $em->persist($zoneStorage);
101
            $em->flush();
102
            $this->addFlash('info', 'gestock.settings.add_ok');
103
104
            if ($form->get('save')->isSubmitted()) {
105
                $url = $this->redirect($this->generateUrl('gs_install_st4'));
106
            } elseif ($form->get('addmore')->isSubmitted()) {
107
                $url = $this->redirect($this->generateUrl('gs_install_st4_2'));
108
            }
109
            return $this->redirect($this->generateUrl('gs_install_st4_2'));
110
        }
111
112
        return array('zonestorage' => $zoneStorage, 'form' => $form->createView());
113
    }
114
115
    /**
116
     * Etape 4.3 de l'installation.
@@ 127-149 (lines=23) @@
124
     *
125
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
126
     */
127
    public function step43Action(Request $request)
128
    {
129
        $unitStorage = new UnitStorage();
130
        $form = $this->createForm(new UnitStorageType(), $unitStorage, array(
131
            'action' => $this->generateUrl('gs_install_st4_3')
132
        ));
133
134
        if ($form->handleRequest($request)->isValid()) {
135
            $em = $this->getDoctrine()->getManager();
136
            $em->persist($unitStorage);
137
            $em->flush();
138
            $this->addFlash('info', 'gestock.settings.add_ok');
139
140
            if ($form->get('save')->isSubmitted()) {
141
                $url = $this->redirect($this->generateUrl('gs_install_st4'));
142
            } elseif ($form->get('addmore')->isSubmitted()) {
143
                $url = $this->redirect($this->generateUrl('gs_install_st4_3'));
144
            }
145
            return $this->redirect($this->generateUrl('gs_install_st4_3'));
146
        }
147
148
        return array('unitstorage' => $unitStorage, 'form' => $form->createView());
149
    }
150
151
    /**
152
     * Etape 4.4 de l'installation.
@@ 163-185 (lines=23) @@
160
     *
161
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
162
     */
163
    public function step44Action(Request $request)
164
    {
165
        $tva = new Tva();
166
        $form = $this->createForm(new TvaType(), $tva, array(
167
            'action' => $this->generateUrl('gs_install_st4_4')
168
        ));
169
170
        if ($form->handleRequest($request)->isValid()) {
171
            $em = $this->getDoctrine()->getManager();
172
            $em->persist($tva);
173
            $em->flush();
174
            $this->addFlash('info', 'gestock.settings.add_ok');
175
176
            if ($form->get('save')->isSubmitted()) {
177
                $url = $this->redirect($this->generateUrl('gs_install_st4'));
178
            } elseif ($form->get('addmore')->isSubmitted()) {
179
                $url = $this->redirect($this->generateUrl('gs_install_st4_4'));
180
            }
181
            return $this->redirect($this->generateUrl('gs_install_st4_4'));
182
        }
183
184
        return array('tva' => $tva, 'form' => $form->createView());
185
    }
186
}
187