Passed
Push — master ( fcf8a0...ba2801 )
by Mihail
04:49
created

Newcontent::actionIndex()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 3
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace Apps\Controller\Admin;
4
5
use Ffcms\Core\App;
6
use Extend\Core\Arch\AdminController;
7
use Apps\Model\Admin\Newcontent\FormSettings;
8
9
/**
10
 * Admin controller of new content widget.
11
 */
12
class Newcontent extends AdminController
13
{
14
    const VERSION = 0.1;
15
    
16
    public $type = 'widget';
17
18
    /**
19
     * Show widget settings
20
     * @return string
21
     */
22
    public function actionIndex()
23
    {
24
        // init settings model
25
        $model = new FormSettings($this->getConfigs());
26
        
27
        // check if request is submited
28
        if ($model->send() && $model->validate()) {
29
            $this->setConfigs($model->getResult());
30
            App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
31
        }
32
        
33
        // render viewer
34
        return App::$View->render('index', [
35
            'model' => $model->export()
36
        ]);
37
    }
38
}