AddController::add()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 3
nop 0
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
namespace Rudolf\Modules\Galleries\One\Admin;
4
5
use Rudolf\Framework\Controller\AdminController;
6
7
class AddController extends AdminController
8
{
9
    /**
10
     * @throws \Exception
11
     */
12
    public function add()
13
    {
14
        $model = new AddModel();
15
16
        $form = new AddForm();
17
        $form->setModel($model);
18
19
        // if data was send
20
        if (!empty($_POST)) {
21
            $form->handle($_POST);
22
23
            if ($form->isValid() && $id = $form->add()) {
24
                $model->flushCache('galleries');
25
                $this->redirect(DIR.'/admin/galleries/edit/'.$id);
26
            }
27
28
            $form->displayAlerts();
29
        }
30
31
        $view = new AddView();
32
        $view->addGallery($form->getDataToDisplay());
33
        $view->render();
34
    }
35
}
36