Conditions | 2 |
Paths | 2 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
12 | public function html(Request $request, Response $response, Admin $app, $entityName) |
||
13 | { |
||
14 | $id = $request->getAttribute('id'); |
||
15 | |||
16 | $form = static::createForm($app, $entityName, $id); |
||
17 | $form->loadFromPsr7($request); |
||
18 | |||
19 | if ($form->validate()) { |
||
20 | $app->getEntity($entityName)->update($id, $form['data']->val()); |
||
21 | |||
22 | return new RedirectResponse($app->getRoute('read', [ |
||
23 | 'entity' => $entityName, |
||
24 | 'id' => $id, |
||
25 | ])); |
||
26 | } |
||
27 | |||
28 | $response->getBody()->write( |
||
29 | $app['templates']->render('pages/read', [ |
||
30 | 'entityName' => $entityName, |
||
31 | 'form' => $form, |
||
32 | 'id' => $id, |
||
33 | ]) |
||
34 | ); |
||
35 | |||
36 | return $response->withStatus(400); |
||
37 | } |
||
38 | } |
||
39 |