Actually hook up the memoizer for UserRole.
This commit is contained in:
parent
e6b69a23e8
commit
d60f36f86f
1 changed files with 9 additions and 7 deletions
|
@ -179,6 +179,7 @@ class UserRole implements ArrayAccess, HasRankInterface {
|
|||
return sprintf(self::QUERY_SELECT, sprintf(self::SELECT, self::TABLE));
|
||||
}
|
||||
public static function byId(int $roleId): self {
|
||||
return self::memoizer()->find($roleId, function() use ($roleId) {
|
||||
$object = DB::prepare(
|
||||
self::byQueryBase() . ' WHERE `role_id` = :role'
|
||||
) ->bind('role', $roleId)
|
||||
|
@ -186,6 +187,7 @@ class UserRole implements ArrayAccess, HasRankInterface {
|
|||
if(!$object)
|
||||
throw new UserRoleNotFoundException;
|
||||
return $object;
|
||||
});
|
||||
}
|
||||
public static function byDefault(): self {
|
||||
return self::byId(self::DEFAULT);
|
||||
|
|
Loading…
Add table
Reference in a new issue