Passed
Push — master ( 81f334...c86e8c )
by Mihail
03:35
created

Feedback::actionSettings()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
3
4
namespace Apps\Controller\Admin;
5
6
use Apps\Model\Admin\Feedback\FormSettings;
7
use Extend\Core\Arch\AdminController as Controller;
8
use Ffcms\Core\App;
9
10
/**
11
 * Class Feedback. Control and manage feedback request and answers.
12
 * @package Apps\Controller\Admin
13
 */
14
class Feedback extends Controller
15
{
16
    const VERSION = '1.0.0';
17
    const ITEM_PER_PAGE = 10;
18
19
    public $type = 'app';
20
21
    // import heavy actions
22
    use Feedback\ActionIndex {
23
        index as actionIndex;
24
    }
25
26
    use Feedback\ActionRead {
27
        read as actionRead;
28
    }
29
30
    use Feedback\ActionUpdate {
31
        update as actionUpdate;
32
    }
33
34
    use Feedback\ActionTurn {
35
        turn as actionTurn;
36
    }
37
38
    use Feedback\ActionDelete {
39
        delete as actionDelete;
40
    }
41
42
    /**
43
     * Settings of feedback application
44
     * @return string
45
     * @throws \Ffcms\Core\Exception\SyntaxException
46
     */
47
    public function actionSettings(): ?string
48
    {
49
        // initialize model and pass configs
50
        $model = new FormSettings($this->getConfigs());
51
52
        // check if form is submited to save data
53
        if ($model->send()) {
54
            // is validation passed?
55
            if ($model->validate()) {
56
                // save properties
57
                $this->setConfigs($model->getAllProperties());
58
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
59
                $this->response->redirect('feedback/index');
60
            } else {
61
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
62
            }
63
        }
64
65
        // render view
66
        return $this->view->render('settings', [
67
            'model' => $model
68
        ]);
69
    }
70
}
71