Completed
Push — master ( 6daf10...1140ad )
by Anton
13s
created

DefaultAcl::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class DefaultAcl extends AbstractMigration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    /**
8
     * Migrate Up.
9
     */
10
    public function up()
11
    {
12
        $roles = [
13
            [
14
                'id' => 1,
15
                'name' => 'system'
16
            ],
17
            [
18
                'id' => 2,
19
                'name' => 'admin'
20
            ],
21
            [
22
                'id' => 3,
23
                'name' => 'member'
24
            ],
25
            [
26
                'id' => 4,
27
                'name' => 'guest'
28
            ],
29
        ];
30
        $this->table('acl_roles')->insert($roles)->save();
31
32
        $privileges = [
33
            [
34
                'roleId' => 2,
35
                'module' => 'acl',
36
                'privilege' => 'Management'
37
            ],
38
            [
39
                'roleId' => 2,
40
                'module' => 'acl',
41
                'privilege' => 'View'
42
            ],
43
            [
44
                'roleId' => 2,
45
                'module' => 'api',
46
                'privilege' => 'Users/Id'
47
            ],
48
            [
49
                'roleId' => 2,
50
                'module' => 'api',
51
                'privilege' => 'Users/Profile'
52
            ],
53
            [
54
                'roleId' => 2,
55
                'module' => 'cache',
56
                'privilege' => 'Management'
57
            ],
58
            [
59
                'roleId' => 2,
60
                'module' => 'dashboard',
61
                'privilege' => 'Dashboard'
62
            ],
63
            [
64
                'roleId' => 2,
65
                'module' => 'pages',
66
                'privilege' => 'Management'
67
            ],
68
            [
69
                'roleId' => 2,
70
                'module' => 'system',
71
                'privilege' => 'Info'
72
            ],
73
            [
74
                'roleId' => 2,
75
                'module' => 'users',
76
                'privilege' => 'EditEmail'
77
            ],
78
            [
79
                'roleId' => 2,
80
                'module' => 'users',
81
                'privilege' => 'EditPassword'
82
            ],
83
            [
84
                'roleId' => 2,
85
                'module' => 'users',
86
                'privilege' => 'Management'
87
            ],
88
            [
89
                'roleId' => 2,
90
                'module' => 'users',
91
                'privilege' => 'ViewProfile'
92
            ],
93
            [
94
                'roleId' => 3,
95
                'module' => 'api',
96
                'privilege' => 'Users/Profile'
97
            ],
98
            [
99
                'roleId' => 3,
100
                'module' => 'users',
101
                'privilege' => 'EditEmail'
102
            ],
103
            [
104
                'roleId' => 3,
105
                'module' => 'users',
106
                'privilege' => 'EditPassword'
107
            ],
108
            [
109
                'roleId' => 3,
110
                'module' => 'users',
111
                'privilege' => 'Management'
112
            ],
113
            [
114
                'roleId' => 3,
115
                'module' => 'users',
116
                'privilege' => 'ViewProfile'
117
            ],
118
        ];
119
        $this->table('acl_privileges')->insert($privileges)->save();
120
121
        $usersRoles = [
122
            [
123
                'userId' => 1,
124
                'roleId' => 1
125
            ],
126
            [
127
                'userId' => 2,
128
                'roleId' => 2
129
            ],
130
            [
131
                'userId' => 3,
132
                'roleId' => 3
133
            ],
134
        ];
135
        $this->table('acl_users_roles')->insert($usersRoles)->save();
136
    }
137
138
    /**
139
     * Migrate Down.
140
     */
141
    public function down()
142
    {
143
        $this->execute('DELETE FROM acl_users_roles');
144
        $this->execute('DELETE FROM acl_privileges');
145
        $this->execute('DELETE FROM acl_roles');
146
    }
147
}
148