Skip to content

Commit 26f0c82

Browse files
committed
(fix): accept PermissionType or string in Input for custom permission types
1 parent 3a4ded6 commit 26f0c82

File tree

1 file changed

+6
-6
lines changed
  • src/Database/Validator/Authorization

1 file changed

+6
-6
lines changed

src/Database/Validator/Authorization/Input.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ class Input
1919
/**
2020
* Create a new authorization input.
2121
*
22-
* @param PermissionType $action The action being authorized (e.g., read, write)
22+
* @param PermissionType|string $action The action being authorized (e.g., read, write)
2323
* @param string[] $permissions List of permission strings to check against
2424
*/
25-
public function __construct(PermissionType $action, array $permissions)
25+
public function __construct(PermissionType|string $action, array $permissions)
2626
{
2727
$this->permissions = $permissions;
28-
$this->action = $action->value;
28+
$this->action = $action instanceof PermissionType ? $action->value : $action;
2929
}
3030

3131
/**
@@ -44,12 +44,12 @@ public function setPermissions(array $permissions): self
4444
/**
4545
* Set the action being authorized.
4646
*
47-
* @param PermissionType $action The action name
47+
* @param PermissionType|string $action The action name
4848
* @return self
4949
*/
50-
public function setAction(PermissionType $action): self
50+
public function setAction(PermissionType|string $action): self
5151
{
52-
$this->action = $action->value;
52+
$this->action = $action instanceof PermissionType ? $action->value : $action;
5353

5454
return $this;
5555
}

0 commit comments

Comments
 (0)