@@ 49-71 (lines=23) @@ | ||
46 | * |
|
47 | * @return Response A Response instance |
|
48 | */ |
|
49 | public function addAction(Request $request) |
|
50 | { |
|
51 | $project = new Project(); |
|
52 | $projectForm = $this->createForm(ProjectFormType::class, $project); |
|
53 | ||
54 | if ($request->isMethod('POST')) { |
|
55 | $projectForm->handleRequest($request); |
|
56 | if ($projectForm->isValid()) { |
|
57 | $projectManager = $this->get('packy.repository.project'); |
|
58 | $projectManager->create($project); |
|
59 | ||
60 | return $this->redirect($this->generateUrl('packy_project_overview')); |
|
61 | } |
|
62 | } |
|
63 | ||
64 | return $this->render( |
|
65 | 'AppBundle:Project:form.html.twig', |
|
66 | [ |
|
67 | 'project' => $project, |
|
68 | 'projectForm' => $projectForm->createView(), |
|
69 | ] |
|
70 | ); |
|
71 | } |
|
72 | ||
73 | /** |
|
74 | * @ParamConverter("project", class="AppBundle:Project", options={"id" = "projectId"}) |
|
@@ 142-163 (lines=22) @@ | ||
139 | * |
|
140 | * @return Response A Response instance |
|
141 | */ |
|
142 | public function editAction(Request $request, Project $project) |
|
143 | { |
|
144 | $projectForm = $this->createForm(ProjectFormType::class, $project); |
|
145 | ||
146 | if ($request->isMethod('POST')) { |
|
147 | $projectForm->handleRequest($request); |
|
148 | if ($projectForm->isValid()) { |
|
149 | $projectRepository = $this->get('packy.repository.project'); |
|
150 | $projectRepository->update($project); |
|
151 | ||
152 | return $this->redirect($this->generateUrl('packy_project_overview')); |
|
153 | } |
|
154 | } |
|
155 | ||
156 | return $this->render( |
|
157 | 'AppBundle:Project:form.html.twig', |
|
158 | [ |
|
159 | 'project' => $project, |
|
160 | 'projectForm' => $projectForm->createView(), |
|
161 | ] |
|
162 | ); |
|
163 | } |
|
164 | ||
165 | /** |
|
166 | * @ParamConverter("project", class="AppBundle:Project", options={"id" = "projectId"}) |
@@ 49-73 (lines=25) @@ | ||
46 | * |
|
47 | * @return Response A Response instance |
|
48 | */ |
|
49 | public function addAction(Request $request) |
|
50 | { |
|
51 | $user = new User(); |
|
52 | $userForm = $this->createForm(UserFormType::class, $user); |
|
53 | ||
54 | if ($request->isMethod('POST')) { |
|
55 | $userForm->handleRequest($request); |
|
56 | if ($userForm->isValid()) { |
|
57 | $user->setEnabled(true); |
|
58 | ||
59 | $userRepository = $this->get('packy.repository.user'); |
|
60 | $userRepository->create($user); |
|
61 | ||
62 | return $this->redirect($this->generateUrl('packy_user_overview')); |
|
63 | } |
|
64 | } |
|
65 | ||
66 | return $this->render( |
|
67 | 'AppBundle:User:form.html.twig', |
|
68 | [ |
|
69 | 'user' => $user, |
|
70 | 'userForm' => $userForm->createView(), |
|
71 | ] |
|
72 | ); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * @ParamConverter("user", class="AppBundle:User", options={"id" = "userId"}) |
|
@@ 85-106 (lines=22) @@ | ||
82 | * |
|
83 | * @return Response A Response instance |
|
84 | */ |
|
85 | public function editAction(Request $request, User $user) |
|
86 | { |
|
87 | $userForm = $this->createForm(UserFormType::class, $user); |
|
88 | ||
89 | if ($request->isMethod('POST')) { |
|
90 | $userForm->handleRequest($request); |
|
91 | if ($userForm->isValid()) { |
|
92 | $userRepository = $this->get('packy.repository.user'); |
|
93 | $userRepository->update($user); |
|
94 | ||
95 | return $this->redirect($this->generateUrl('packy_user_overview')); |
|
96 | } |
|
97 | } |
|
98 | ||
99 | return $this->render( |
|
100 | 'AppBundle:User:form.html.twig', |
|
101 | [ |
|
102 | 'user' => $user, |
|
103 | 'userForm' => $userForm->createView(), |
|
104 | ] |
|
105 | ); |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * @ParamConverter("user", class="AppBundle:User", options={"id" = "userId"}) |