API / Minn\Auth / Roles

Roles final class

Minn\Auth\Roles · public/minn/src/Minn/Auth/Roles.php · 68 lines

Role definitions from the site's {prefix}user_roles option, parsed by a bounded scan of the serialized blob, with the seeded contract copy as the fallback for a fresh install.

Uses 2

Constants and properties

privateLEVELS = array ( 'administrator' => 10, 'editor' => 7, 'author' => 2, 'contributor' => 1, 'subscriber' => 0, )
private?array $roles
privatereadonly Minn\Db $db

Promoted from the constructor.

Public

new__construct(Minn\Db $db)#
staticlevel(string $role): int#

The wp_user_level stored beside the capabilities meta.

staticserializeSingle(string $role): string#

The {role: true} capabilities meta in its serialized form.

methodforget(): void#

Drops the parsed map so the next read sees a rewritten option.

methodall(): array#

Every role with its name and capabilities, from the option or the shipped defaults.

staticparse(?string $blob): ?array#

Each role is a string key over a two-entry array of "name" and "capabilities"; the capabilities map is {cap: bool}. Null when the blob has another shape, so the caller can fall back.