Passed
Push — master ( fa3542...0a3787 )
by Mihail
05:11
created

Apps/Controller/Admin/Comments/ActionSettings.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Apps\Controller\Admin\Comments;
4
5
6
use Apps\Model\Admin\Comments\FormSettings;
7
use Ffcms\Core\App;
8
use Ffcms\Core\Arch\View;
9
use Ffcms\Core\Network\Request;
10
use Ffcms\Core\Network\Response;
11
12
/**
13
 * Trait ActionSettings
14
 * @package Apps\Controller\Admin\Comments
15
 * @property Request $request
16
 * @property Response $response
17
 * @property View $view
18
 */
19
trait ActionSettings
20
{
21
    /**
22
     * Comment widget global settings
23
     * @return string
24
     * @throws \Ffcms\Core\Exception\SyntaxException
25
     */
26
    public function settings()
27
    {
28
        // initialize settings model
29
        $model = new FormSettings($this->getConfigs());
0 ignored issues
show
It seems like getConfigs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $model = new FormSettings($this->/** @scrutinizer ignore-call */ getConfigs());
Loading history...
30
31
        // check if form is send
32
        if ($model->send()) {
33
            if ($model->validate()) {
34
                $this->setConfigs($model->getAllProperties());
0 ignored issues
show
It seems like setConfigs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
                $this->/** @scrutinizer ignore-call */ 
35
                       setConfigs($model->getAllProperties());
Loading history...
35
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
36
                $this->response->redirect('comments/index');
37
            } else {
38
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
39
            }
40
        }
41
42
        // render view
43
        return $this->view->render('comments/settings', [
44
            'model' => $model
45
        ]);
46
    }
47
}