-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: Introduce RoleId
and RoleIds
value objects
#3415
base: 9.0
Are you sure you want to change the base?
Conversation
$this->name = $matches[2]; | ||
$this->label = $label ?: $matches[2]; | ||
$this->id = RoleId::fromString($identifier); | ||
$this->label = $label ?: $this->id->getName(); | ||
$this->description = $description; | ||
$this->parentRoles = $parentRoles; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static function fromRoleId(RoleId $id, array $parentRoles = [], string $label = '', string $description = ''): self | |
{ | |
return new ($id->value, array $parentRoles = [], string $label = '', string $description = ''); | |
} | |
public static function fromIdentifierString(string $identifier, array $parentRoles = [], string $label = '', string $description = ''): self | |
{ | |
return new ($identifier, array $parentRoles = [], string $label = '', string $description = ''); | |
} |
And then deprecate the __construct as it is so we can at least open a window for refactoring internally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kitsunet mh, Role::fromRoleId()
and Role::fromIdentifierString()
sounds wrong to me.. But what do you think of
public function __construct(RoleId|string $id, array $parentRoles = [], string $label = '', string $description = '') {
if (is_string($id)) {
$id = RoleId::fromString($id);
}
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sounds good! My thought train was not finished really. I was thinking / hoping how we can refactor towards something like RoleIds $parentRoles or somthing, but the static constructors would not necessarily make that easier :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, totally fair
Resolves: #3414