1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace BristolSU\Module\AssignRoles\Events; |
||
4 | |||
5 | use BristolSU\ControlDB\Contracts\Models\Role; |
||
6 | use BristolSU\ControlDB\Contracts\Models\User; |
||
7 | use BristolSU\Support\Action\Contracts\TriggerableEvent; |
||
8 | |||
9 | class UserAssigned implements TriggerableEvent |
||
0 ignored issues
–
show
|
|||
10 | { |
||
11 | |||
12 | /** |
||
0 ignored issues
–
show
|
|||
13 | * @var User |
||
14 | */ |
||
15 | private $user; |
||
0 ignored issues
–
show
|
|||
16 | /** |
||
0 ignored issues
–
show
|
|||
17 | * @var Role |
||
18 | */ |
||
19 | private $role; |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | 2 | public function __construct(User $user, Role $role) |
|
0 ignored issues
–
show
|
|||
22 | { |
||
23 | 2 | $this->user = $user; |
|
24 | 2 | $this->role = $role; |
|
25 | 2 | } |
|
26 | |||
27 | /** |
||
0 ignored issues
–
show
|
|||
28 | * @inheritDoc |
||
29 | */ |
||
0 ignored issues
–
show
|
|||
30 | public function getFields(): array |
||
31 | { |
||
32 | return [ |
||
33 | 'role_id' => $this->role->id(), |
||
34 | 'position_id' => $this->role->positionId(), |
||
35 | 'position_name' => $this->role->position()->data()->name(), |
||
36 | 'role_name' => $this->role->data()->roleName(), |
||
37 | 'role_email' => $this->role->data()->email(), |
||
38 | 'user_id' => $this->user->id(), |
||
39 | 'user_first_name' => $this->user->data()->firstName(), |
||
40 | 'user_last_name' => $this->user->data()->lastName(), |
||
41 | 'user_preferred_name' => $this->user->data()->preferredName(), |
||
42 | 'user_email' => $this->user->data()->email() |
||
43 | ]; |
||
44 | } |
||
45 | |||
46 | /** |
||
0 ignored issues
–
show
|
|||
47 | * @inheritDoc |
||
48 | */ |
||
0 ignored issues
–
show
|
|||
49 | public static function getFieldMetaData(): array |
||
50 | { |
||
51 | return [ |
||
52 | 'role_id' => [ |
||
53 | 'label' => 'Role ID', |
||
54 | 'helptext' => 'ID of the role that was assigned to' |
||
55 | ], |
||
56 | 'position_id' => [ |
||
57 | 'label' => 'Position ID', |
||
58 | 'helptext' => 'ID of the position that was assigned to' |
||
59 | ], |
||
60 | 'position_name' => [ |
||
61 | 'label' => 'Position Name', |
||
62 | 'helptext' => 'Name of the position that was assigned to' |
||
63 | ], |
||
64 | 'role_name' => [ |
||
65 | 'label' => 'Role Name', |
||
66 | 'helptext' => 'Custom name for the role that was assigned to' |
||
67 | ], |
||
68 | 'role_email' => [ |
||
69 | 'label' => 'Role Email', |
||
70 | 'helptext' => 'Email of the role that was assigned to' |
||
71 | ], |
||
72 | 'user_id' => [ |
||
73 | 'label' => 'User ID', |
||
74 | 'helptext' => 'ID of the user that was assigned' |
||
75 | ], |
||
76 | 'user_first_name' => [ |
||
77 | 'label' => 'User First Name', |
||
78 | 'helptext' => 'First name of the user that was assigned' |
||
79 | ], |
||
80 | 'user_last_name' => [ |
||
81 | 'label' => 'User Last Name', |
||
82 | 'helptext' => 'Last name of the user that was assigned' |
||
83 | ], |
||
84 | 'user_preferred_name' => [ |
||
85 | 'label' => 'User Preferred Name', |
||
86 | 'helptext' => 'Preferred name of the user that was assigned' |
||
87 | ], |
||
88 | 'user_email' => [ |
||
89 | 'label' => 'User Email', |
||
90 | 'helptext' => 'Email of the user that was assigned' |
||
91 | ] |
||
92 | ]; |
||
93 | } |
||
94 | } |