Passed
Push — master ( 73d14c...8a9029 )
by Mihail
04:02
created

Profile::actionFielddelete()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 21
rs 9.6111
c 0
b 0
f 0
cc 5
nc 4
nop 1
1
<?php
2
3
namespace Apps\Controller\Admin;
4
5
6
use Apps\Model\Admin\Profile\FormSettings;
7
use Extend\Core\Arch\AdminController;
8
use Ffcms\Core\App;
9
10
/**
11
 * Class Profile. Admin controller of profile application.
12
 * @package Apps\Controller\Admin
13
 */
14
class Profile extends AdminController
15
{
16
    const VERSION = '1.0.0';
17
    const ITEM_PER_PAGE = 10;
18
19
    public $type = 'app';
20
21
    /** Import heavy actions */
22
    use Profile\ActionIndex {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Admin\Profile\ActionIndex requires the property $query which is not provided by Apps\Controller\Admin\Profile.
Loading history...
23
        index as actionIndex;
24
    }
25
26
    use Profile\ActionUpdate {
0 ignored issues
show
introduced by
The trait Apps\Controller\Admin\Profile\ActionUpdate requires some properties which are not provided by Apps\Controller\Admin\Profile: $user_id, $user
Loading history...
27
        profileUpdate as actionUpdate;
28
    }
29
30
    use Profile\ActionFieldList {
31
        profileFieldList as actionFieldlist;
32
    }
33
34
    use Profile\ActionFieldUpdate {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Admin\Profile\ActionFieldUpdate requires the property $id which is not provided by Apps\Controller\Admin\Profile.
Loading history...
35
        profileFieldUpdate as actionFieldupdate;
36
    }
37
38
    use Profile\ActionFieldDelete {
39
        profileFieldDelete as actionFielddelete;
40
    }
41
42
    /**
43
     * Show profiles settings
44
     * @return string
45
     * @throws \Ffcms\Core\Exception\SyntaxException
46
     */
47
    public function actionSettings()
48
    {
49
        $model = new FormSettings($this->getConfigs());
50
51
        if ($model->send()) {
52
            if ($model->validate()) {
53
                $this->setConfigs($model->getAllProperties());
54
                App::$Session->getFlashBag()->add('success', __('Settings is successful updated'));
55
                $this->response->redirect('profile/index');
56
            } else {
57
                App::$Session->getFlashBag()->add('error', __('Form validation is failed'));
58
            }
59
        }
60
61
        return $this->view->render('profile/settings', [
62
            'model' => $model
63
        ]);
64
    }
65
}
66