|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
declare(strict_types=1); |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\DataFixtures; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Entity\Role; |
|
10
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture; |
|
11
|
|
|
use Doctrine\Persistence\ObjectManager; |
|
12
|
|
|
|
|
13
|
|
|
class RoleFixtures extends Fixture |
|
14
|
|
|
{ |
|
15
|
|
|
public function load(ObjectManager $manager): void |
|
16
|
|
|
{ |
|
17
|
|
|
$roles = [ |
|
18
|
|
|
[ |
|
19
|
|
|
'code' => 'INVITEE', |
|
20
|
|
|
'constantValue' => 1, |
|
21
|
|
|
'title' => 'Invitee', |
|
22
|
|
|
'description' => 'Invited users', |
|
23
|
|
|
'systemRole' => true, |
|
24
|
|
|
], |
|
25
|
|
|
[ |
|
26
|
|
|
'code' => 'STUDENT', |
|
27
|
|
|
'constantValue' => 2, |
|
28
|
|
|
'title' => 'Student', |
|
29
|
|
|
'description' => 'Students of courses or sessions', |
|
30
|
|
|
'systemRole' => true, |
|
31
|
|
|
], |
|
32
|
|
|
[ |
|
33
|
|
|
'code' => 'TEACHER', |
|
34
|
|
|
'constantValue' => 3, |
|
35
|
|
|
'title' => 'Teacher', |
|
36
|
|
|
'description' => 'Teachers of courses or sessions', |
|
37
|
|
|
'systemRole' => true, |
|
38
|
|
|
], |
|
39
|
|
|
[ |
|
40
|
|
|
'code' => 'ADMIN', |
|
41
|
|
|
'constantValue' => 4, |
|
42
|
|
|
'title' => 'Administrator', |
|
43
|
|
|
'description' => 'Platform administrators', |
|
44
|
|
|
'systemRole' => true, |
|
45
|
|
|
], |
|
46
|
|
|
[ |
|
47
|
|
|
'code' => 'SUPER_ADMIN', |
|
48
|
|
|
'constantValue' => 5, |
|
49
|
|
|
'title' => 'Super Administrator', |
|
50
|
|
|
'description' => 'Super admin users', |
|
51
|
|
|
'systemRole' => true, |
|
52
|
|
|
], |
|
53
|
|
|
[ |
|
54
|
|
|
'code' => 'GLOBAL_ADMIN', |
|
55
|
|
|
'constantValue' => 6, |
|
56
|
|
|
'title' => 'Global Administrator', |
|
57
|
|
|
'description' => 'Global admin users', |
|
58
|
|
|
'systemRole' => true, |
|
59
|
|
|
], |
|
60
|
|
|
[ |
|
61
|
|
|
'code' => 'HR', |
|
62
|
|
|
'constantValue' => 7, |
|
63
|
|
|
'title' => 'HR Manager', |
|
64
|
|
|
'description' => 'Human resources managers', |
|
65
|
|
|
'systemRole' => false, |
|
66
|
|
|
], |
|
67
|
|
|
[ |
|
68
|
|
|
'code' => 'QUESTION_MANAGER', |
|
69
|
|
|
'constantValue' => 8, |
|
70
|
|
|
'title' => 'Question Bank Manager', |
|
71
|
|
|
'description' => 'Manages the question bank across courses', |
|
72
|
|
|
'systemRole' => false, |
|
73
|
|
|
], |
|
74
|
|
|
[ |
|
75
|
|
|
'code' => 'SESSION_MANAGER', |
|
76
|
|
|
'constantValue' => 9, |
|
77
|
|
|
'title' => 'Session Manager', |
|
78
|
|
|
'description' => 'Manages sessions and session content', |
|
79
|
|
|
'systemRole' => false, |
|
80
|
|
|
], |
|
81
|
|
|
[ |
|
82
|
|
|
'code' => 'STUDENT_BOSS', |
|
83
|
|
|
'constantValue' => 10, |
|
84
|
|
|
'title' => 'Student Boss', |
|
85
|
|
|
'description' => 'Manages groups of students', |
|
86
|
|
|
'systemRole' => false, |
|
87
|
|
|
], |
|
88
|
|
|
]; |
|
89
|
|
|
|
|
90
|
|
|
foreach ($roles as $roleData) { |
|
91
|
|
|
$existing = $manager->getRepository(Role::class) |
|
92
|
|
|
->findOneBy(['code' => $roleData['code']]); |
|
93
|
|
|
|
|
94
|
|
|
if ($existing) { |
|
95
|
|
|
continue; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
$role = new Role(); |
|
99
|
|
|
$role->setCode($roleData['code']); |
|
100
|
|
|
$role->setConstantValue($roleData['constantValue']); |
|
101
|
|
|
$role->setTitle($roleData['title']); |
|
102
|
|
|
$role->setDescription($roleData['description']); |
|
103
|
|
|
$role->setSystemRole($roleData['systemRole']); |
|
104
|
|
|
$manager->persist($role); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$manager->flush(); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|