Completed
Push — master ( eb9757...48e21b )
by Dmitry
02:45
created

Initer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 2
c 4
b 1
f 0
lcom 0
cbo 1
dl 0
loc 87
ccs 64
cts 64
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 78 1
A reinit() 0 5 1
1
<?php
2
3
/*
4
 * RBAC implementation for HiPanel
5
 *
6
 * @link      https://github.com/hiqdev/hipanel-rbac
7
 * @package   hipanel-rbac
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\rbac;
13
14
/**
15
 * Initer for AuthManager.
16
 *
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class Initer
20 5
{
21
    public static function init(AuthManager $auth)
22 5
    {
23 5
        $auth->setRole('role:client');
24 5
        $auth->setRole('role:support');
25 5
        $auth->setRole('role:admin');
26 5
        $auth->setRole('role:manager');
27 5
        $auth->setRole('role:reseller');
28
        $auth->setRole('role:owner');
29 5
30 5
        $auth->setRole('role:domain.freezer');
31 5
        $auth->setRole('role:bill.manager');
32
        $auth->setRole('role:document.manager');
33 5
34 5
        $auth->setPermission('restore-password');
35 5
        $auth->setPermission('deposit');
36 5
        $auth->setPermission('support');
37 5
        $auth->setPermission('manage');
38 5
        $auth->setPermission('admin');
39 5
        $auth->setPermission('resell');
40
        $auth->setPermission('own');
41 5
42 5
        $auth->setPermission('domain.pay');
43 5
        $auth->setPermission('domain.freeze');
44 5
        $auth->setPermission('domain.unfreeze');
45
        $auth->setPermission('domain.set-contacts');
46 5
47
        $auth->setPermission('document.manage');
48 5
49 5
        $auth->setPermission('mailing.prepare');
50
        $auth->setPermission('mailing.send');
51 5
52
        $auth->setPermission('contact.force-verify');
53 5
54
        $auth->setPermission('server.pay');
55 5
56 5
        $auth->setPermission('bill.create');
57 5
        $auth->setPermission('bill.update');
58
        $auth->setPermission('bill.delete');
59 5
60 5
        $auth->setChild('role:client',                  'restore-password');
61 5
        $auth->setChild('role:client',                  'deposit');
62 5
        $auth->setChild('role:client',                  'domain.pay');
63
        $auth->setChild('role:client',                  'server.pay');
64 5
65
        $auth->setChild('role:support',                 'support');
66 5
67 5
        $auth->setChild('role:admin',                   'role:support');
68 5
        $auth->setChild('role:admin',                   'admin');
69
        $auth->setChild('role:admin',                   'contact.force-verify');
70 5
71 5
        $auth->setChild('role:manager',                 'role:support');
72 5
        $auth->setChild('role:manager',                 'role:document.manager');
73 5
        $auth->setChild('role:manager',                 'manage');
74 5
        $auth->setChild('role:manager',                 'domain.pay');
75 5
        $auth->setChild('role:manager',                 'server.pay');
76 5
        $auth->setChild('role:manager',                 'contact.force-verify');
77 5
        $auth->setChild('role:manager',                 'mailing.prepare');
78
        $auth->setChild('role:manager',                 'mailing.send');
79 5
80 5
        $auth->setChild('role:reseller',                'role:manager');
81 5
        $auth->setChild('role:reseller',                'role:bill.manager');
82 5
        $auth->setChild('role:reseller',                'resell');
83
        $auth->setChild('role:reseller',                'deposit');
84 5
85 5
        $auth->setChild('role:owner',                   'role:manager');
86 5
        $auth->setChild('role:owner',                   'role:bill.manager');
87 5
        $auth->setChild('role:owner',                   'resell');
88
        $auth->setChild('role:owner',                   'own');
89 5
90 5
        $auth->setChild('role:domain.freezer',          'domain.freeze');
91
        $auth->setChild('role:domain.freezer',          'domain.unfreeze');
92 5
93 5
        $auth->setChild('role:bill.manager',            'bill.create');
94 5
        $auth->setChild('role:bill.manager',            'bill.update');
95
        $auth->setChild('role:bill.manager',            'bill.delete');
96 5
97 5
        $auth->setChild('role:document.manager',         'document.manage');
98
    }
99 5
100
    public static function reinit(AuthManager $auth)
101 5
    {
102 5
        $auth->removeAll();
103 5
        static::init($auth);
104
    }
105
}
106