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
|
|
|
use App\Entity\Category; |
37
|
|
|
use App\Form\BaseEntityAdminForm; |
38
|
|
|
use App\Form\CategoryAdminForm; |
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("/category") |
50
|
|
|
* @package App\Controller |
51
|
|
|
*/ |
52
|
|
|
class CategoryController extends BaseAdminController |
53
|
|
|
{ |
54
|
|
|
|
55
|
|
|
protected $entity_class = Category::class; |
56
|
|
|
protected $twig_template = 'AdminPages/CategoryAdmin.html.twig'; |
57
|
|
|
protected $form_class = CategoryAdminForm::class; |
58
|
|
|
protected $route_base = "category"; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="category_edit") |
62
|
|
|
* @Route("/{id}/", requirements={"id"="\d+"}) |
63
|
|
|
*/ |
64
|
|
|
public function edit(Category $entity, Request $request, EntityManagerInterface $em) |
65
|
|
|
{ |
66
|
|
|
return $this->_edit($entity, $request, $em); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Route("/new", name="category_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="category_delete", methods={"DELETE"}) |
82
|
|
|
*/ |
83
|
|
|
public function delete(Request $request, Category $entity, StructuralElementRecursionHelper $recursionHelper) |
84
|
|
|
{ |
85
|
|
|
return $this->_delete($request, $entity, $recursionHelper); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @Route("/export", name="category_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="category_export") |
102
|
|
|
* @param Request $request |
103
|
|
|
* @param AttachmentType $entity |
104
|
|
|
*/ |
105
|
|
|
public function exportEntity(Category $entity, EntityExporter $exporter, Request $request) |
106
|
|
|
{ |
107
|
|
|
return $this->_exportEntity($entity, $exporter, $request); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
} |