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; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
use App\Entity\AttachmentType; |
36
|
|
|
use App\Form\BaseEntityAdminForm; |
37
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
38
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
39
|
|
|
use Symfony\Component\HttpFoundation\Request; |
40
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @Route("/attachment_type") |
44
|
|
|
* @package App\Controller |
45
|
|
|
*/ |
46
|
|
|
class AttachmentTypeController extends AbstractController |
47
|
|
|
{ |
48
|
|
|
/** |
49
|
|
|
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="attachment_type_edit") |
50
|
|
|
* @Route("/{id}/", requirements={"id"="\d+"}) |
51
|
|
|
*/ |
52
|
|
|
public function edit(AttachmentType $entity, Request $request, EntityManagerInterface $em) |
53
|
|
|
{ |
54
|
|
|
|
55
|
|
|
$form = $this->createForm(BaseEntityAdminForm::class, $entity); |
56
|
|
|
|
57
|
|
|
$form->handleRequest($request); |
58
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
59
|
|
|
$em->persist($entity); |
60
|
|
|
$em->flush(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $this->render('AdminPages/AttachmentTypeAdmin.html.twig', [ |
64
|
|
|
'entity' => $entity, |
65
|
|
|
'form' => $form->createView() |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Route("/new") |
71
|
|
|
* |
72
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
73
|
|
|
*/ |
74
|
|
|
public function new(Request $request, EntityManagerInterface $em) |
75
|
|
|
{ |
76
|
|
|
$new_entity = new AttachmentType(); |
77
|
|
|
|
78
|
|
|
$this->denyAccessUnlessGranted('create', $new_entity); |
79
|
|
|
|
80
|
|
|
$form = $this->createForm(BaseEntityAdminForm::class, $new_entity); |
81
|
|
|
|
82
|
|
|
$form->handleRequest($request); |
83
|
|
|
|
84
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
85
|
|
|
$em->persist($new_entity); |
86
|
|
|
$em->flush(); |
87
|
|
|
//$this->addFlash('success', $translator->trans('part.created_flash')); |
88
|
|
|
|
89
|
|
|
return $this->redirectToRoute('attachment_type_edit', ['id' => $new_entity->getID()]); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return $this->render('AdminPages/AttachmentTypeAdmin.html.twig', [ |
93
|
|
|
'entity' => $new_entity, |
94
|
|
|
'form' => $form->createView() |
95
|
|
|
]); |
96
|
|
|
} |
97
|
|
|
} |