Passed
Push — master ( eb9638...42e076 )
by Mihail
07:15
created

Comments::actionSettings()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 11

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 21
loc 21
rs 9.3142
cc 3
eloc 11
nc 3
nop 0
1
<?php
2
3
namespace Apps\Controller\Admin;
4
5
6
use Apps\ActiveRecord\Session;
7
use Apps\Model\Admin\Comments\FormSettings;
8
use Extend\Core\Arch\AdminController;
9
use Ffcms\Core\App;
10
11
/**
12
 * Class Comments. Admin controller for management user comments.
13
 * This class provide general admin implementation of control for user comments and its settings.
14
 * @package Apps\Controller\Admin
15
 */
16
class Comments extends AdminController
17
{
18
    const VERSION = 0.1;
19
20
    public $type = 'widget';
21
22
    public function actionIndex()
23
    {
24
        return App::$View->render('index', [
25
26
        ]);
27
    }
28
29 View Code Duplication
    public function actionSettings()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        // initialize settings model
32
        $model = new FormSettings($this->getConfigs());
33
34
        // check if form is send
35
        if ($model->send()) {
36
            if ($model->validate()) {
37
                $this->setConfigs($model->getAllProperties());
38
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
39
                App::$Response->redirect('comments/index');
40
            } else {
41
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
42
            }
43
        }
44
45
        // render view
46
        return App::$View->render('settings', [
47
            'model' => $model
48
        ]);
49
    }
50
51
52
53
54
}