Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Database/Helpers/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,9 @@ public static function member(string $identifier): self
{
return new self('member', $identifier);
}

public static function project(string $identifier, string $dimension = ''): self
{
return new self('project', $identifier, $dimension);
}
}
14 changes: 12 additions & 2 deletions src/Database/Validator/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Roles extends Validator
public const ROLE_TEAM = 'team';
public const ROLE_MEMBER = 'member';
public const ROLE_LABEL = 'label';
public const ROLE_PROJECT = 'project';

public const ROLES = [
self::ROLE_ANY,
Expand All @@ -24,6 +25,7 @@ class Roles extends Validator
self::ROLE_TEAM,
self::ROLE_MEMBER,
self::ROLE_LABEL,
self::ROLE_PROJECT,
];

protected string $message = 'Roles Error';
Expand Down Expand Up @@ -108,6 +110,16 @@ class Roles extends Validator
'required' => false,
],
],
self::ROLE_PROJECT => [
'identifier' => [
'allowed' => true,
'required' => true,
],
'dimension' => [
'allowed' => true,
'required' => true,
],
]
];

// Dimensions
Expand Down Expand Up @@ -286,8 +298,6 @@ protected function isValidRole(
}

// Required and has no dimension
// PHPStan complains because there are currently no dimensions that are required, but there might be in future
// @phpstan-ignore-next-line
if ($allowed && $required && empty($dimension)) {
$this->message = 'Role "' . $role . '"' . ' must have a dimension value.';
return false;
Expand Down