Code Duplication    Length = 23-23 lines in 4 locations

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

@@ 105-127 (lines=23) @@
102
     *
103
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
104
     */
105
    public function step2Action(Request $request)
106
    {
107
        $em = $this->getDoctrine()->getManager();
108
        $ctCompany = count($em->getRepository('AppBundle:Company')->findAll());
109
        $company = new Company();
110
        $message = null;
111
        
112
        if ($ctCompany > 0 && $request->getMethod() == 'GET') {
113
            $message = 'gestock.install.st2.yet_exist';
114
        }
115
        $form = $this->createForm(new CompanyType(), $company, array(
116
            'action' => $this->generateUrl('gs_install_st2')
117
        ));
118
        if ($form->handleRequest($request)->isValid()) {
119
            $em = $this->getDoctrine()->getManager();
120
            $em->persist($company);
121
            $em->flush();
122
123
            return $this->redirect($this->generateUrl('gs_install_st2'));
124
        }
125
126
        return array('message' => $message, 'company' => $company, 'form'    => $form->createView());
127
    }
128
129
    /**
130
     * Etape 3 de l'installation.
@@ 141-163 (lines=23) @@
138
     *
139
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
140
     */
141
    public function step3Action(Request $request)
142
    {
143
        $em = $this->getDoctrine()->getManager();
144
        $ctSettings = count($em->getRepository('AppBundle:Settings')->findAll());
145
        $settings = new Settings();
146
        $message = null;
147
        
148
        if ($ctSettings > 0 && $request->getMethod() == 'GET') {
149
            $message = 'gestock.install.st3.yet_exist';
150
        }
151
        $form = $this->createForm(new SettingsType(), $settings, array(
152
            'action' => $this->generateUrl('gs_install_st3')
153
        ));
154
        if ($form->handleRequest($request)->isValid()) {
155
            $em = $this->getDoctrine()->getManager();
156
            $em->persist($settings);
157
            $em->flush();
158
159
            return $this->redirect($this->generateUrl('gs_install_st3'));
160
        }
161
162
        return array('message' => $message, 'settings' => $settings, 'form' => $form->createView());
163
    }
164
165
    /**
166
     * Etape 4 de l'installation.
@@ 192-214 (lines=23) @@
189
     *
190
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
191
     */
192
    public function step5Action(Request $request)
193
    {
194
        $em = $this->getDoctrine()->getManager();
195
        $ctSupplier = count($em->getRepository('AppBundle:Supplier')->findAll());
196
        $suppliers = new Supplier();
197
        $message = null;
198
        
199
        if ($ctSupplier > 0 && $request->getMethod() == 'GET') {
200
            $message = 'gestock.install.st5.yet_exist';
201
        }
202
        $form = $this->createForm(new SupplierType(), $suppliers, array(
203
            'action' => $this->generateUrl('gs_install_st5')
204
        ));
205
        if ($form->handleRequest($request)->isValid()) {
206
            $em = $this->getDoctrine()->getManager();
207
            $em->persist($suppliers);
208
            $em->flush();
209
210
            return $this->redirect($this->generateUrl('gs_install_st5'));
211
        }
212
213
        return array('message' => $message, 'suppliers' => $suppliers, 'form' => $form->createView());
214
    }
215
216
    /**
217
     * Etape 6 de l'installation.
@@ 228-250 (lines=23) @@
225
     *
226
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
227
     */
228
    public function step6Action(Request $request)
229
    {
230
        $em = $this->getDoctrine()->getManager();
231
        $ctArticles = count($em->getRepository('AppBundle:Article')->findAll());
232
        $articles = new Article();
233
        $message = null;
234
        
235
        if ($ctArticles > 0 && $request->getMethod() == 'GET') {
236
            $message = 'gestock.install.st6.yet_exist';
237
        }
238
        $form = $this->createForm(new ArticleType(), $articles, array(
239
            'action' => $this->generateUrl('gs_install_st6')
240
        ));
241
        if ($form->handleRequest($request)->isValid()) {
242
            $em = $this->getDoctrine()->getManager();
243
            $em->persist($articles);
244
            $em->flush();
245
246
            return $this->redirect($this->generateUrl('gs_install_st6'));
247
        }
248
249
        return array('message' => $message, 'articles' => $articles, 'form' => $form->createView());
250
    }
251
    
252
    /**
253
     * Etape 7 de l'installation.