Code Duplication    Length = 18-23 lines in 6 locations

Apps/Controller/Admin/Comments.php 1 location

@@ 279-299 (lines=21) @@
276
     * @throws \Ffcms\Core\Exception\NativeException
277
     * @throws \Ffcms\Core\Exception\SyntaxException
278
     */
279
    public function actionSettings()
280
    {
281
        // initialize settings model
282
        $model = new FormSettings($this->getConfigs());
283
284
        // check if form is send
285
        if ($model->send()) {
286
            if ($model->validate()) {
287
                $this->setConfigs($model->getAllProperties());
288
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
289
                App::$Response->redirect('comments/index');
290
            } else {
291
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
292
            }
293
        }
294
295
        // render view
296
        return App::$View->render('settings', [
297
            'model' => $model->filter()
298
        ]);
299
    }
300
301
302

Apps/Controller/Admin/Content.php 1 location

@@ 383-403 (lines=21) @@
380
     * @throws SyntaxException
381
     * @throws NativeException
382
     */
383
    public function actionSettings()
384
    {
385
        // init model with config array data
386
        $model = new FormSettings($this->getConfigs());
387
388
        // check if form is send
389
        if ($model->send()) {
390
            if ($model->validate()) {
391
                $this->setConfigs($model->getAllProperties());
392
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
393
                App::$Response->redirect('content/index');
394
            } else {
395
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
396
            }
397
        }
398
399
        // draw response
400
        return App::$View->render('settings', [
401
            'model' => $model->filter()
402
        ]);
403
    }
404
}

Apps/Controller/Admin/Feedback.php 1 location

@@ 246-268 (lines=23) @@
243
     * @throws \Ffcms\Core\Exception\NativeException
244
     * @throws \Ffcms\Core\Exception\SyntaxException
245
     */
246
    public function actionSettings()
247
    {
248
        // initialize model and pass configs
249
        $model = new FormSettings($this->getConfigs());
250
251
        // check if form is submited to save data
252
        if ($model->send()) {
253
            // is validation passed?
254
            if ($model->validate()) {
255
                // save properties
256
                $this->setConfigs($model->getAllProperties());
257
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
258
                App::$Response->redirect('feedback/index');
259
            } else {
260
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
261
            }
262
        }
263
264
        // render view
265
        return App::$View->render('settings', [
266
            'model' => $model->filter()
267
        ]);
268
    }
269
270
}

Apps/Controller/Admin/Profile.php 1 location

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

Apps/Controller/Admin/User.php 1 location

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

Apps/Controller/Admin/Search.php 1 location

@@ 20-41 (lines=22) @@
17
18
    public $type = 'app';
19
20
    public function actionIndex()
21
    {
22
        // initialize model and pass configs inside
23
        $model = new FormSettings($this->getConfigs());
24
25
        // check if submit request is sended
26
        if ($model->send()) {
27
            if ($model->validate()) {
28
                // save configurations
29
                $this->setConfigs($model->getAllProperties());
30
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
31
                App::$Response->redirect('search/index');
32
            } else {
33
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
34
            }
35
        }
36
37
        // render output view
38
        return App::$View->render('settings', [
39
            'model' => $model->filter()
40
        ]);
41
    }
42
43
}