| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Lines | 14 |
| Ratio | 60.87 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function edit($id) |
||
|
|
|||
| 17 | { |
||
| 18 | $model = new TypeEditModel(); |
||
| 19 | $view = new TypeEditView(); |
||
| 20 | |||
| 21 | View Code Duplication | if (isset($_POST['update'])) { |
|
| 22 | if ($model->edit($id, $_POST)) { |
||
| 23 | AlertsCollection::add(new Alert( |
||
| 24 | 'success', |
||
| 25 | 'Zaktualizowano!' |
||
| 26 | )); |
||
| 27 | $this->redirectTo(DIR.'/admin/appearance/menu/edit-type/'.$id); |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | AlertsCollection::add(new Alert( |
||
| 31 | 'error', |
||
| 32 | 'Coś się zepsuło!' |
||
| 33 | )); |
||
| 34 | } |
||
| 35 | |||
| 36 | $view->display($model->getMenuTypeById($id)); |
||
| 37 | $view->render('admin'); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |
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: