Completed
Push — master ( ccbc72...0c935c )
by Laurent
14s
created

UnitStorageController::editAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * UnitStorageController controller des unités de stockage.
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\Settings\Divers;
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\UnitStorage;
23
24
/**
25
 * UnitStorage controller.
26
 *
27
 * @category Controller
28
 *
29
 * @Route("/admin/settings/divers/unitstorage")
30
 */
31
class UnitStorageController extends AbstractController
32
{
33
    /**
34
     * Lists all UnitStorage entities.
35
     *
36
     * @Route("/", name="unitstorage")
37
     * @Method("GET")
38
     * @Template()
39
     */
40
    public function indexAction(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...
41
    {
42
        $etm = $this->getDoctrine()->getManager();
43
        $qb = $etm->getRepository('AppBundle:UnitStorage')->createQueryBuilder('u');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $qb. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
44
        $paginator = $this->get('knp_paginator')->paginate($qb, $request->query->get('page', 1), 20);
45
        return array(
46
            'paginator' => $paginator,
47
        );
48
    }
49
50
    /**
51
     * Finds and displays a UnitStorage entity.
52
     *
53
     * @Route("/{slug}/show", name="unitstorage_show")
54
     * @Method("GET")
55
     * @Template()
56
     */
57
    public function showAction(UnitStorage $unitstorage)
58
    {
59
        $return = $this->abstractShowAction($unitstorage, 'unitstorage');
60
61
        return $return;
62
    }
63
64
    /**
65
     * Displays a form to create a new UnitStorage entity.
66
     *
67
     * @Route("/new", name="unitstorage_new")
68
     * @Method("GET")
69
     * @Template()
70
     */
71
    public function newAction()
72
    {
73
        $return = $this->abstractNewAction(
74
            'UnitStorage',
75
            'AppBundle\Entity\UnitStorage',
76
            'AppBundle\Form\Type\UnitStorageType'
77
        );
78
79
        return $return;
80
    }
81
82
    /**
83
     * Creates a new UnitStorage entity.
84
     *
85
     * @Route("/create", name="unitstorage_create")
86
     * @Method("POST")
87
     * @Template("AppBundle:Settings/Divers/UnitStorage:new.html.twig")
88
     */
89
    public function createAction(Request $request)
90
    {
91
        $return = $this->abstractCreateAction(
92
            $request,
93
            'unitstorage',
94
            'AppBundle\Entity\UnitStorage',
95
            'AppBundle\Form\Type\UnitStorageType'
96
        );
97
98
        return $return;
99
    }
100
101
    /**
102
     * Displays a form to edit an existing UnitStorage entity.
103
     *
104
     * @Route("/{slug}/edit", name="unitstorage_edit")
105
     * @Method("GET")
106
     * @Template()
107
     */
108
    public function editAction(UnitStorage $unitstorage)
109
    {
110
        $return = $this->abstractEditAction(
111
            $unitstorage,
112
            'unitstorage',
113
            'AppBundle\Form\Type\UnitStorageType'
114
        );
115
116
        return $return;
117
    }
118
119
    /**
120
     * Edits an existing UnitStorage entity.
121
     *
122
     * @Route("/{slug}/update", name="unitstorage_update")
123
     * @Method("PUT")
124
     * @Template("AppBundle:Settings/Divers/UnitStorage:edit.html.twig")
125
     */
126
    public function updateAction(UnitStorage $unitstorage, Request $request)
127
    {
128
        $return = $this->abstractUpdateAction(
129
            $unitstorage,
130
            $request,
131
            'unitstorage',
132
            'AppBundle\Form\Type\UnitStorageType'
133
        );
134
135
        return $return;
136
    }
137
138
    /**
139
     * Deletes a UnitStorage entity.
140
     *
141
     * @Route("/{id}/delete", name="unitstorage_delete", requirements={"id"="\d+"})
142
     * @Method("DELETE")
143
     */
144
    public function deleteAction(UnitStorage $unitstorage, Request $request)
145
    {
146
        $this->abstractDeleteAction($unitstorage, $request, 'unitstorage');
147
148
        return $this->redirectToRoute('unitstorage');
149
    }
150
}
151