Code Duplication    Length = 18-22 lines in 4 locations

Apps/Controller/Admin/Search.php 1 location

@@ 25-46 (lines=22) @@
22
     * @throws \Ffcms\Core\Exception\SyntaxException
23
     * @throws \Ffcms\Core\Exception\NativeException
24
     */
25
    public function actionIndex()
26
    {
27
        // initialize model and pass configs inside
28
        $model = new FormSettings($this->getConfigs());
29
30
        // check if submit request is sended
31
        if ($model->send()) {
32
            if ($model->validate()) {
33
                // save configurations
34
                $this->setConfigs($model->getAllProperties());
35
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
36
                $this->response->redirect('search/index');
37
            } else {
38
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
39
            }
40
        }
41
42
        // render output view
43
        return $this->view->render('settings', [
44
            'model' => $model
45
        ]);
46
    }
47
}
48

Apps/Controller/Admin/User.php 1 location

@@ 185-204 (lines=20) @@
182
     * @throws \Ffcms\Core\Exception\SyntaxException
183
     * @throws \Ffcms\Core\Exception\NativeException
184
     */
185
    public function actionSettings()
186
    {
187
        // load model and pass property's as argument
188
        $model = new FormUserSettings($this->getConfigs());
189
190
        if ($model->send()) {
191
            if ($model->validate()) {
192
                $this->setConfigs($model->getAllProperties());
193
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
194
                $this->response->redirect('user/index');
195
            } else {
196
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
197
            }
198
        }
199
200
        // render view
201
        return $this->view->render('settings', [
202
            'model' => $model
203
        ]);
204
    }
205
206
    /**
207
     * Send invite to user by email

Apps/Controller/Admin/Comments.php 1 location

@@ 73-93 (lines=21) @@
70
     * @return string
71
     * @throws \Ffcms\Core\Exception\SyntaxException
72
     */
73
    public function actionSettings()
74
    {
75
        // initialize settings model
76
        $model = new FormSettings($this->getConfigs());
77
78
        // check if form is send
79
        if ($model->send()) {
80
            if ($model->validate()) {
81
                $this->setConfigs($model->getAllProperties());
82
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
83
                $this->response->redirect('comments/index');
84
            } else {
85
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
86
            }
87
        }
88
89
        // render view
90
        return $this->view->render('settings', [
91
            'model' => $model
92
        ]);
93
    }
94
}
95

Apps/Controller/Admin/Profile.php 1 location

@@ 190-207 (lines=18) @@
187
     * @return string
188
     * @throws \Ffcms\Core\Exception\SyntaxException
189
     */
190
    public function actionSettings()
191
    {
192
        $model = new FormSettings($this->getConfigs());
193
194
        if ($model->send()) {
195
            if ($model->validate()) {
196
                $this->setConfigs($model->getAllProperties());
197
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
198
                $this->response->redirect('profile/index');
199
            } else {
200
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
201
            }
202
        }
203
204
        return $this->view->render('settings', [
205
            'model' => $model
206
        ]);
207
    }
208
}
209