Conditions | 3 |
Paths | 3 |
Total Lines | 24 |
Lines | 15 |
Ratio | 62.5 % |
Changes | 0 |
1 | <?php |
||
18 | public function edit($id) |
||
|
|||
19 | { |
||
20 | $model = new ItemEditModel(); |
||
21 | $view = new ItemEditView(); |
||
22 | |||
23 | View Code Duplication | if (isset($_POST['update'])) { |
|
24 | if ($model->edit($id, $_POST)) { |
||
25 | AlertsCollection::add(new Alert( |
||
26 | 'success', |
||
27 | 'Zaktualizowano!' |
||
28 | )); |
||
29 | $this->redirectTo(DIR.'/admin/appearance/menu/edit-item/'.$id); |
||
30 | |||
31 | return; |
||
32 | } |
||
33 | AlertsCollection::add(new Alert( |
||
34 | 'error', |
||
35 | 'Coś się zepsuło!' |
||
36 | )); |
||
37 | } |
||
38 | |||
39 | $view->display($model->getInfo($id), (new Model())->getTypes(), (new FrontModel())->getMenuItems()); |
||
40 | $view->render('admin'); |
||
41 | } |
||
42 | } |
||
43 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: