-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathUserType.php
More file actions
96 lines (85 loc) · 2.12 KB
/
Copy pathUserType.php
File metadata and controls
96 lines (85 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/*
* Copyright (c) 2025-2026 Netresearch DTT GmbH
* SPDX-License-Identifier: AGPL-3.0-only
*/
declare(strict_types=1);
namespace App\Enum;
/**
* User type enumeration for role-based access control.
*/
enum UserType: string
{
case UNKNOWN = '';
case USER = 'USER';
case DEV = 'DEV';
case PL = 'PL';
case ADMIN = 'ADMIN';
/**
* Get Symfony roles for this user type.
*
* @return string[]
*/
public function getRoles(): array
{
return match ($this) {
self::UNKNOWN => ['ROLE_USER'],
self::USER, self::DEV => ['ROLE_USER'],
// PL has ROLE_ADMIN for v4 compatibility (PL was admin in v4)
// TODO: Remove ROLE_ADMIN from PL when proper ADMIN users are established
self::PL => ['ROLE_USER', 'ROLE_PL', 'ROLE_ADMIN'],
self::ADMIN => ['ROLE_USER', 'ROLE_ADMIN'],
};
}
/**
* Check if this user type has administrative privileges.
* Note: PL has admin rights for v4 compatibility.
*/
public function isAdmin(): bool
{
return self::ADMIN === $this || self::PL === $this;
}
/**
* Check if this user type has project lead privileges.
*/
public function isPl(): bool
{
return self::PL === $this;
}
/**
* Check if this user type has developer privileges.
*/
public function isDev(): bool
{
return self::DEV === $this;
}
/**
* Get display name for this user type.
*/
public function getDisplayName(): string
{
return match ($this) {
self::UNKNOWN => 'Unknown/Not Configured',
self::USER => 'User',
self::DEV => 'Developer',
self::PL => 'Project Lead',
self::ADMIN => 'Administrator',
};
}
/**
* Get all available user types.
*
* @return self[]
*/
public static function all(): array
{
return self::cases();
}
/**
* Check if this is a valid configured user type.
*/
public function isConfigured(): bool
{
return self::UNKNOWN !== $this;
}
}