Passed
Push — master ( 6221c1...b56763 )
by Mihail
05:30
created

Search::actionIndex()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 22
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 11
c 1
b 1
f 0
nc 3
nop 0
dl 22
loc 22
rs 9.2
1
<?php
2
3
namespace Apps\Controller\Admin;
4
5
6
use Apps\Model\Admin\Search\FormSettings;
7
use Extend\Core\Arch\AdminController;
8
use Ffcms\Core\App;
9
10
/**
11
 * Class Search. Admin configuration controller for search app.
12
 * @package Apps\Controller\Admin
13
 */
14
class Search extends AdminController
15
{
16
    const VERSION = 0.1;
17
18
    public $type = 'app';
19
20 View Code Duplication
    public function actionIndex()
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...
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
}