Completed
Push — master ( 1839ce...4b984d )
by Laurent
03:35
created

Install4Controller::step41Action()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 17

Duplication

Lines 27
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 27
loc 27
rs 8.5806
cc 4
eloc 17
nc 4
nop 1
1
<?php
2
/**
3
 * InstallController controller d'installation de l'application GLSR.
4
 *
5
 * PHP Version 5
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2014 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version   since 1.0.0
12
 *
13
 * @link      https://github.com/Dev-Int/glsr
14
 */
15
namespace AppBundle\Controller\Install;
16
17
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
18
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
19
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
20
use Symfony\Component\HttpFoundation\Request;
21
use AppBundle\Entity\FamilyLog;
22
use AppBundle\Form\Type\FamilyLogType;
23
use AppBundle\Entity\ZoneStorage;
24
use AppBundle\Form\Type\ZoneStorageType;
25
use AppBundle\Entity\UnitStorage;
26
use AppBundle\Form\Type\UnitStorageType;
27
use AppBundle\Entity\Tva;
28
use AppBundle\Form\Type\TvaType;
29
30
/**
31
 * class InstallController
32
 *
33
 * @category Controller
34
 *
35
 * @Route("/install/step4")
36
 */
37
class Install4Controller extends InstallController
38
{
39
    /**
40
     * Etape 4.1 de l'installation.
41
     * Cronfiguration de l'application (Famille logistique).
42
     *
43
     * @Route("/1", name="gs_install_st4_1")
44
     * @Method({"POST","GET"})
45
     * @Template("AppBundle:install:step4.html.twig")
46
     *
47
     * @param Symfony\Component\HttpFoundation\Request $request Requète du formulaire
0 ignored issues
show
Documentation introduced by
Should the type for parameter $request not be Request?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
48
     *
49
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
0 ignored issues
show
Documentation introduced by
Should the return type not be \Symfony\Component\HttpF...omponent\Form\FormView>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
50
     */
51 View Code Duplication
    public function step41Action(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
65
            } elseif ($form->get('addmore')->isSubmitted()) {
66
                $url = $this->redirect($this->generateUrl('gs_install_st4_1'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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.
81
     * Cronfiguration de l'application (Zone de stockage).
82
     *
83
     * @Route("/2", name="gs_install_st4_2")
84
     * @Method({"POST","GET"})
85
     * @Template("AppBundle:install:step4.html.twig")
86
     *
87
     * @param Symfony\Component\HttpFoundation\Request $request Requète du formulaire
0 ignored issues
show
Documentation introduced by
Should the type for parameter $request not be Request?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
88
     *
89
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
0 ignored issues
show
Documentation introduced by
Should the return type not be \Symfony\Component\HttpF...omponent\Form\FormView>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
90
     */
91 View Code Duplication
    public function step42Action(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
106
            } elseif ($form->get('addmore')->isSubmitted()) {
107
                $url = $this->redirect($this->generateUrl('gs_install_st4_2'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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.
117
     * Cronfiguration de l'application (Unité de stockage).
118
     *
119
     * @Route("/3", name="gs_install_st4_3")
120
     * @Method({"POST","GET"})
121
     * @Template("AppBundle:install:step4.html.twig")
122
     *
123
     * @param Symfony\Component\HttpFoundation\Request $request Requète du formulaire
0 ignored issues
show
Documentation introduced by
Should the type for parameter $request not be Request?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
124
     *
125
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
0 ignored issues
show
Documentation introduced by
Should the return type not be \Symfony\Component\HttpF...omponent\Form\FormView>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
126
     */
127 View Code Duplication
    public function step43Action(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
142
            } elseif ($form->get('addmore')->isSubmitted()) {
143
                $url = $this->redirect($this->generateUrl('gs_install_st4_3'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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.
153
     * Cronfiguration de l'application (Taux de T.V.A.).
154
     *
155
     * @Route("/4", name="gs_install_st4_4")
156
     * @Method({"POST","GET"})
157
     * @Template("AppBundle:install:step4.html.twig")
158
     *
159
     * @param Symfony\Component\HttpFoundation\Request $request Requète du formulaire
0 ignored issues
show
Documentation introduced by
Should the type for parameter $request not be Request?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
160
     *
161
     * @return Symfony\Component\HttpFoundation\Response Rendue de la page
0 ignored issues
show
Documentation introduced by
Should the return type not be \Symfony\Component\HttpF...omponent\Form\FormView>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
162
     */
163 View Code Duplication
    public function step44Action(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
178
            } elseif ($form->get('addmore')->isSubmitted()) {
179
                $url = $this->redirect($this->generateUrl('gs_install_st4_4'));
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
180
            }
181
            return $this->redirect($this->generateUrl('gs_install_st4_4'));
182
        }
183
184
        return array('tva' => $tva, 'form' => $form->createView());
185
    }
186
}
187