Completed
Pull Request — master (#58)
by Laurent
03:26
created

FamilyLogController::createAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
/**
3
 * FamilyLogController controller des familles logistiques.
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\FamilyLog;
23
24
/**
25
 * FamilyLog controller.
26
 *
27
 * @category Controller
28
 *
29
 * @Route("/admin/settings/divers/familylog")
30
 */
31
class FamilyLogController extends AbstractController
32
{
33
    /**
34
     * Lists all FamilyLog entities.
35
     *
36
     * @Route("/", name="familylog")
37
     * @Method("GET")
38
     * @Template()
39
     */
40
    public function indexAction()
41
    {
42
        $etm = $this->getDoctrine()->getManager();
43
        $entities = $etm->getRepository('AppBundle:FamilyLog')->childrenHierarchy();
44
        
45
        return array(
46
            'entities'  => $entities,
47
        );
48
    }
49
50
    /**
51
     * Finds and displays a FamilyLog entity.
52
     *
53
     * @Route("/{slug}/show", name="familylog_show")
54
     * @Method("GET")
55
     * @Template()
56
     */
57
    public function showAction(FamilyLog $familylog)
58
    {
59
        $return = $this->abstractShowAction($familylog, 'familylog');
60
61
        return $return;
62
    }
63
64
    /**
65
     * Displays a form to create a new FamilyLog entity.
66
     *
67
     * @Route("/new", name="familylog_new")
68
     * @Method("GET")
69
     * @Template()
70
     */
71
    public function newAction()
72
    {
73
        $return = $this->abstractNewAction(
74
            'FamilyLog',
75
            'AppBundle\Entity\FamilyLog',
76
            'AppBundle\Form\Type\FamilyLogType'
77
        );
78
79
        return $return;
80
    }
81
82
    /**
83
     * Creates a new FamilyLog entity.
84
     *
85
     * @Route("/create", name="familylog_create")
86
     * @Method("POST")
87
     * @Template("AppBundle:FamilyLog:new.html.twig")
88
     */
89
    public function createAction(Request $request)
90
    {
91
        $return = $this->abstractCreateAction(
92
            $request,
93
            'familylog',
94
            'AppBundle\Entity\FamilyLog',
95
            'AppBundle\Form\Type\FamilyLogType'
96
        );
97
98
        return $return;
99
    }
100
101
    /**
102
     * Displays a form to edit an existing FamilyLog entity.
103
     *
104
     * @Route("/{slug}/edit", name="familylog_edit")
105
     * @Method("GET")
106
     * @Template()
107
     */
108
    public function editAction(FamilyLog $familylog)
109
    {
110
        $return = $this->abstractEditAction(
111
            $familylog,
112
            'familylog',
113
            'AppBundle\Form\Type\FamilyLogType'
114
        );
115
116
        return $return;
117
    }
118
119
    /**
120
     * Edits an existing FamilyLog entity.
121
     *
122
     * @Route("/{slug}/update", name="familylog_update")
123
     * @Method("PUT")
124
     * @Template("AppBundle:FamilyLog:edit.html.twig")
125
     */
126
    public function updateAction(FamilyLog $familylog, Request $request)
127
    {
128
        $return = $this->abstractUpdateAction(
129
            $familylog,
130
            $request,
131
            'familylog',
132
            'AppBundle\Form\Type\FamilyLogType'
133
        );
134
135
        return $return;
136
    }
137
138
    /**
139
     * Deletes a FamilyLog entity.
140
     *
141
     * @Route("/{id}/delete", name="familylog_delete", requirements={"id"="\d+"})
142
     * @Method("DELETE")
143
     */
144
    public function deleteAction(FamilyLog $familylog, Request $request)
145
    {
146
        $this->abstractDeleteAction(
147
            $familylog,
148
            $request,
149
            'familylog'
150
        );
151
152
        return $this->redirectToRoute('familylog');
153
    }
154
}
155