| Conditions | 4 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | public function add() |
||
|
|
|||
| 10 | { |
||
| 11 | $model = new AddModel(); |
||
| 12 | |||
| 13 | $form = new AddForm(); |
||
| 14 | $form->setModel($model); |
||
| 15 | |||
| 16 | // if data was send |
||
| 17 | if (!empty($_POST)) { |
||
| 18 | $form->handle($_POST); |
||
| 19 | |||
| 20 | if ($form->isValid() and $id = $form->add($_POST)) { |
||
| 21 | $this->redirect(DIR.'/admin/galleries/edit/'.$id); |
||
| 22 | } |
||
| 23 | |||
| 24 | $form->dispalyAlerts(); |
||
| 25 | } |
||
| 26 | |||
| 27 | $view = new AddView(); |
||
| 28 | $view->addGallery($form->getDataToDisplay()); |
||
| 29 | $view->render('admin'); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |
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: