Completed
Push — Recipes ( c99128 )
by Laurent
13:15
created

UnitController::editAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * UnitController controller des unités.
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 GIT: <git_id>
12
 *
13
 * @link      https://github.com/Dev-Int/glsr
14
 */
15
namespace AppBundle\Controller\Settings\Diverse;
16
17
use Symfony\Component\HttpFoundation\Request;
18
use AppBundle\Controller\AbstractController;
19
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
20
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
21
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
22
use AppBundle\Entity\Settings\Diverse\Unit;
23
use AppBundle\Form\Type\Settings\Diverse\UnitType;
24
25
/**
26
 * Unit controller.
27
 *
28
 * @category Controller
29
 *
30
 * @Route("/admin/settings/diverse/unit")
31
 */
32 View Code Duplication
class UnitController extends AbstractController
1 ignored issue
show
Duplication introduced by
This class 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...
33
{
34
    /**
35
     * Lists all Unit entities.
36
     *
37
     * @Route("/", name="unit")
38
     * @Method("GET")
39
     * @Template()
40
     *
41
     * @param \Symfony\Component\HttpFoundation\Request $request Paginate request
42
     * @return array
43
     */
44
    public function indexAction(Request $request)
45
    {
46
        $return = $this->abstractIndexAction('Settings\Diverse\Unit', 'unit', $request);
47
48
        return $return;
49
    }
50
51
    /**
52
     * Finds and displays a Unit entity.
53
     *
54
     * @Route("/{slug}/show", name="unit_show")
55
     * @Method("GET")
56
     * @Template()
57
     *
58
     * @param \AppBundle\Entity\Settings\Diverse\Unit $unit UnitStaorage to display
59
     * @return array
60
     */
61
    public function showAction(Unit $unit)
62
    {
63
        $return = $this->abstractShowAction($unit, 'unit');
64
65
        return $return;
66
    }
67
68
    /**
69
     * Displays a form to create a new Unit entity.
70
     *
71
     * @Route("/new", name="unit_new")
72
     * @Method("GET")
73
     * @Template()
74
     *
75
     * @return array
76
     */
77
    public function newAction()
78
    {
79
        $return = $this->abstractNewAction(
80
            'Settings\Diverse\Unit',
81
            'AppBundle\Entity\Settings\Diverse\Unit',
82
            UnitType::class,
83
            'unit'
84
        );
85
86
        return $return;
87
    }
88
89
    /**
90
     * Creates a new Unit entity.
91
     *
92
     * @Route("/create", name="unit_create")
93
     * @Method("POST")
94
     * @Template("AppBundle:Settings/Diverse/Unit:new.html.twig")
95
     *
96
     * @param \Symfony\Component\HttpFoundation\Request $request Form request
97
     * @return array
98
     */
99
    public function createAction(Request $request)
100
    {
101
        $return = $this->abstractCreateAction(
102
            $request,
103
            'Settings\Diverse\Unit',
104
            'AppBundle\Entity\Settings\Diverse\Unit',
105
            UnitType::class,
106
            'unit'
107
        );
108
109
        return $return;
110
    }
111
112
    /**
113
     * Displays a form to edit an existing Unit entity.
114
     *
115
     * @Route("/{slug}/edit", name="unit_edit")
116
     * @Method("GET")
117
     * @Template()
118
     *
119
     * @param \AppBundle\Entity\Settings\Diverse\Unit $unit Unit item to edit
120
     * @return array
121
     */
122
    public function editAction(Unit $unit)
123
    {
124
        $return = $this->abstractEditAction(
125
            $unit,
126
            'unit',
127
            UnitType::class
128
        );
129
130
        return $return;
131
    }
132
133
    /**
134
     * Edits an existing Unit entity.
135
     *
136
     * @Route("/{slug}/update", name="unit_update")
137
     * @Method("PUT")
138
     * @Template("AppBundle:Settings/Diverse/Unit:edit.html.twig")
139
     *
140
     * @param \AppBndle\Entity\Settings\Diverse\Unit $unit Unit item to update
141
     * @param \Symfony\Component\HttpFoundation\Request     $request     Form request
142
     * @return array
143
     */
144
    public function updateAction(Unit $unit, Request $request)
145
    {
146
        $return = $this->abstractUpdateAction(
147
            $unit,
148
            $request,
149
            'unit',
150
            UnitType::class
151
        );
152
153
        return $return;
154
    }
155
156
    /**
157
     * Deletes a Unit entity.
158
     *
159
     * @Route("/{id}/delete", name="unit_delete", requirements={"id"="\d+"})
160
     * @Method("DELETE")
161
     *
162
     * @param \AppBundle\Entity\Settings\Diverse\Unit   $unit    Unit item to delete
163
     * @param \Symfony\Component\HttpFoundation\Request $request Form request
164
     * @return array
165
     */
166
    public function deleteAction(Unit $unit, Request $request)
167
    {
168
        $this->abstractDeleteAction($unit, $request, 'unit');
169
170
        return $this->redirectToRoute('unit');
171
    }
172
}
173