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