| Conditions | 3 | 
| Paths | 3 | 
| Total Lines | 32 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 16 | public function add() | ||
| 17 |     { | ||
| 18 |         if (isset($_POST['add'])) { | ||
| 19 | $model = new ItemAddModel(); | ||
| 20 | $id = $model->add($_POST); | ||
| 21 |             if ($id) { | ||
| 22 | AlertsCollection::add(new Alert( | ||
| 23 | 'success', | ||
| 24 | 'Poprawnie dodano!' | ||
| 25 | )); | ||
| 26 | $this->redirectTo(DIR.'/admin/appearance/menu/edit-item/'.$id); | ||
| 27 | return; | ||
| 28 | } | ||
| 29 | AlertsCollection::add(new Alert( | ||
| 30 | 'error', | ||
| 31 | 'Coś się zepsuło!' | ||
| 32 | )); | ||
| 33 | } | ||
| 34 | |||
| 35 | $view = new ItemAddView(); | ||
| 36 | $view->display(new MenuItem([ | ||
| 37 | 'id' => -1, | ||
| 38 | 'parent_id' => 0, | ||
| 39 | 'title' => '', | ||
| 40 | 'slug' => '', | ||
| 41 | 'caption' => '', | ||
| 42 | 'menu_type' => 'main', | ||
| 43 | 'item_type' => '', | ||
| 44 | 'position' => 0, | ||
| 45 | ]), (new Model())->getTypes(), (new FrontModel())->getMenuItems()); | ||
| 46 | $view->render(); | ||
| 47 | } | ||
| 48 | } | ||
| 49 |