Passed
Push — master ( 34a8e1...345dac )
by Mihail
04:51
created

Content::actionSettings()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Apps\Controller\Admin;
4
5
use Apps\ActiveRecord\ContentCategory;
6
use Apps\Model\Admin\Content\FormSettings;
7
use Extend\Core\Arch\AdminController;
8
use Ffcms\Core\App;
9
use Ffcms\Core\Exception\SyntaxException;
10
11
/**
12
 * Class Content. Admin controller to manage & control contents
13
 * @package Apps\Controller\Admin
14
 */
15
class Content extends AdminController
16
{
17
    const VERSION = '1.0.0';
18
    const ITEM_PER_PAGE = 10;
19
20
    public $type = 'app';
21
22
    // import heavy actions
23
    use Content\ActionIndex {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Admin\Content\ActionIndex requires the property $query which is not provided by Apps\Controller\Admin\Content.
Loading history...
24
        index as actionIndex;
25
    }
26
27
    use Content\ActionUpdate {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Admin\Content\ActionUpdate requires the property $id which is not provided by Apps\Controller\Admin\Content.
Loading history...
28
        update as actionUpdate;
29
    }
30
31
    use Content\ActionDelete {
32
        delete as actionDelete;
33
    }
34
35
    use Content\ActionRestore {
36
        restore as actionRestore;
37
    }
38
39
    use Content\ActionClear {
40
        clear as actionClear;
41
    }
42
43
    use Content\ActionCategoryList {
44
        contentCategoryList as actionCategories;
45
    }
46
47
    use Content\ActionCategoryDelete {
48
        categoryDelete as actionCategorydelete;
49
    }
50
51
    use Content\ActionCategoryUpdate {
0 ignored issues
show
introduced by
The trait Apps\Controller\Admin\Content\ActionCategoryUpdate requires some properties which are not provided by Apps\Controller\Admin\Content: $query, $id
Loading history...
52
        categoryUpdate as actionCategoryupdate;
53
    }
54
55
    use Content\ActionGlobDelete {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Admin\Content\ActionGlobDelete requires the property $query which is not provided by Apps\Controller\Admin\Content.
Loading history...
56
        globDelete as actionGlobdelete;
57
    }
58
59
    use Content\ActionPublish {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Admin\Content\ActionPublish requires the property $query which is not provided by Apps\Controller\Admin\Content.
Loading history...
60
        publish as actionPublish;
61
    }
62
63
    /**
64
     * Show settings form with prepared model
65
     * @return string
66
     * @throws SyntaxException
67
     */
68
    public function actionSettings(): ?string
69
    {
70
        // init model with config array data
71
        $model = new FormSettings($this->getConfigs());
72
73
        // check if form is send
74
        if ($model->send()) {
75
            if ($model->validate()) {
76
                $this->setConfigs($model->getAllProperties());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $model->getAllProperties() targeting Ffcms\Core\Arch\Model::getAllProperties() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
77
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
78
                $this->response->redirect('content/index');
79
            } else {
80
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
81
            }
82
        }
83
84
        // draw response
85
        return $this->view->render('content/settings', [
86
            'model' => $model
87
        ]);
88
    }
89
}
90