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,13 +179,15 @@ class UserRole implements ArrayAccess, HasRankInterface {
|
||||||
return sprintf(self::QUERY_SELECT, sprintf(self::SELECT, self::TABLE));
|
return sprintf(self::QUERY_SELECT, sprintf(self::SELECT, self::TABLE));
|
||||||
}
|
}
|
||||||
public static function byId(int $roleId): self {
|
public static function byId(int $roleId): self {
|
||||||
$object = DB::prepare(
|
return self::memoizer()->find($roleId, function() use ($roleId) {
|
||||||
self::byQueryBase() . ' WHERE `role_id` = :role'
|
$object = DB::prepare(
|
||||||
) ->bind('role', $roleId)
|
self::byQueryBase() . ' WHERE `role_id` = :role'
|
||||||
->fetchObject(self::class);
|
) ->bind('role', $roleId)
|
||||||
if(!$object)
|
->fetchObject(self::class);
|
||||||
throw new UserRoleNotFoundException;
|
if(!$object)
|
||||||
return $object;
|
throw new UserRoleNotFoundException;
|
||||||
|
return $object;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public static function byDefault(): self {
|
public static function byDefault(): self {
|
||||||
return self::byId(self::DEFAULT);
|
return self::byId(self::DEFAULT);
|
||||||
|
|
Loading…
Add table
Reference in a new issue