Completed
Push — master ( 2ea0dc...0826f5 )
by Jan
04:38 queued 01:31
created

DeviceController::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * part-db version 0.1
5
 * Copyright (C) 2005 Christoph Lechner
6
 * http://www.cl-projects.de/
7
 *
8
 * part-db version 0.2+
9
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
10
 * http://code.google.com/p/part-db/
11
 *
12
 * Part-DB Version 0.4+
13
 * Copyright (C) 2016 - 2019 Jan Böhmer
14
 * https://github.com/jbtronics
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
29
 *
30
 */
31
32
namespace App\Controller\AdminPages;
33
34
35
use App\Entity\AttachmentType;
36
37
use App\Entity\Device;
38
use App\Form\BaseEntityAdminForm;
39
use App\Services\EntityExporter;
40
use App\Services\EntityImporter;
41
use App\Services\StructuralElementRecursionHelper;
42
use Doctrine\ORM\EntityManagerInterface;
43
use Symfony\Component\HttpFoundation\Request;
44
use Symfony\Component\HttpFoundation\Response;
45
use Symfony\Component\Routing\Annotation\Route;
46
use Symfony\Component\Serializer\SerializerInterface;
47
48
/**
49
 * @Route("/device")
50
 * @package App\Controller
51
 */
52
class DeviceController extends BaseAdminController
53
{
54
55
    protected $entity_class = Device::class;
56
    protected $twig_template = 'AdminPages/DeviceAdmin.html.twig';
57
    protected $form_class = BaseEntityAdminForm::class;
58
    protected $route_base = "device";
59
60
    /**
61
     * @Route("/{id}/edit", requirements={"id"="\d+"}, name="device_edit")
62
     * @Route("/{id}/", requirements={"id"="\d+"})
63
     */
64
    public function edit(Device $entity, Request $request, EntityManagerInterface $em)
65
    {
66
        return $this->_edit($entity, $request, $em);
67
    }
68
69
    /**
70
     * @Route("/new", name="device_new")
71
     * @Route("/")
72
     *
73
     * @return \Symfony\Component\HttpFoundation\Response
74
     */
75
    public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
76
    {
77
        return $this->_new($request, $em, $importer);
78
    }
79
80
    /**
81
     * @Route("/{id}", name="device_delete", methods={"DELETE"})
82
     */
83
    public function delete(Request $request, Device $entity, StructuralElementRecursionHelper $recursionHelper)
84
    {
85
        return $this->_delete($request, $entity, $recursionHelper);
86
    }
87
88
    /**
89
     * @Route("/export", name="device_export_all")
90
     * @param Request $request
91
     * @param SerializerInterface $serializer
92
     * @param EntityManagerInterface $em
93
     * @return Response
94
     */
95
    public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
96
    {
97
        return $this->_exportAll($em, $exporter, $request);
98
    }
99
100
    /**
101
     * @Route("/{id}/export", name="device_export")
102
     * @param Request $request
103
     * @param AttachmentType $entity
104
     */
105
    public function exportEntity(Device $entity, EntityExporter $exporter, Request $request)
106
    {
107
        return $this->_exportEntity($entity, $exporter, $request);
108
    }
109
110
}