Passed
Push — master ( 05e7db...c14628 )
by vistart
04:22
created

MyController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 60
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actions() 0 20 1
B behaviors() 0 34 1
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\organization\web\organization\controllers;
14
15
use Yii;
16
use yii\filters\AccessControl;
17
use yii\filters\VerbFilter;
18
use yii\web\Controller;
19
20
/**
21
 * @version 1.0
22
 * @author vistart <[email protected]>
23
 */
24
class MyController extends Controller
25
{
26
    public $layout = 'main';
27
28
    public function actions()
29
    {
30
        return [
31
            'index' => [
32
                'class' => 'rhosocial\organization\web\organization\controllers\my\IndexAction',
33
            ],
34
            'set-up-organization' => [
35
                'class' => 'rhosocial\organization\web\organization\controllers\my\SetUpOrganizationAction',
36
            ],
37
            'revoke' => [
38
                'class' => 'rhosocial\organization\web\organization\controllers\my\RevokeAction',
39
            ],
40
            'member' => [
41
                'class' => 'rhosocial\organization\web\organization\controllers\my\MemberAction',
42
            ],
43
            'add-member' => [
44
                'class' => 'rhosocial\organization\web\organization\controllers\my\AddMemberAction',
45
            ],
46
        ];
47
    }
48
49
    public function behaviors()
50
    {
51
        return [
52
            'access' => [
53
                'class' => AccessControl::class,
54
                'rules' => [
55
                    [
56
                        'allow' => false,
57
                        'roles' => ['?'],
58
                    ],
59
                    [ // Disallow user who does not have `setUpOrganization` permission to access this `set-up-organization` action.
60
                        'actions' => ['set-up-organization'],
61
                        'allow' => false,
62
                        'matchCallback' => function ($rule, $action) {
0 ignored issues
show
Unused Code introduced by
The parameter $rule is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
                            return !Yii::$app->user->can('setUpOrganization');
64
                        },
65
                        'denyCallback' => function ($rule, $action) {
0 ignored issues
show
Unused Code introduced by
The parameter $rule is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
                            throw new UnauthorizedHttpException(Yii::t('organization', 'You do not have access to set up new organization.'));
67
                        },
68
                    ],
69
                    [
70
                        'allow' => true,
71
                        'roles' => ['@'],
72
                    ]
73
                ],
74
            ],
75
            'verbs' => [
76
                'class' => VerbFilter::class,
77
                'actions' => [
78
                     'revoke' => ['post'],
79
                ]
80
            ],
81
        ];
82
    }
83
}
84