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

ActionSettings::settings()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 12

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 4
nop 0
dl 22
loc 22
rs 8.9197
c 0
b 0
f 0
1
<?php
2
3
namespace Apps\Controller\Admin\Main;
4
5
use Apps\Model\Admin\Main\FormSettings;
6
use Ffcms\Core\App;
7
use Ffcms\Core\Arch\View;
8
use Ffcms\Core\Network\Request;
9
use Ffcms\Core\Network\Response;
10
11
/**
12
 * Trait ActionSettings
13
 * @package Apps\Controller\Admin\Main
14
 * @property Request $request
15
 * @property Response $response
16
 * @property View $view
17
 */
18
trait ActionSettings
19
{
20
    /**
21
     * Manage settings in web
22
     * @return string
23
     * @throws \Ffcms\Core\Exception\SyntaxException
24
     */
25 View Code Duplication
    public function settings()
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...
26
    {
27
        // init settings model and process post send
28
        $model = new FormSettings(true);
29
        if ($model->send()) {
30
            if ($model->validate()) {
31
                if ($model->makeSave()) {
32
                    // show message about successful save and take system some time ;)
33
                    return $this->view->render('settings_save');
34
                } else {
35
                    App::$Session->getFlashBag()->add('error', __('Configuration file is not writable! Check /Private/Config/ dir and files'));
36
                }
37
            } else {
38
                App::$Session->getFlashBag()->add('error', __('Validation of form data is failed!'));
39
            }
40
        }
41
42
        // render output view
43
        return $this->view->render('settings', [
44
            'model' => $model
45
        ]);
46
    }
47
}
48