API / Minn\Runtime / UserQueryRoles

UserQueryRoles final class

Minn\Runtime\UserQueryRoles · public/minn/src/Minn/Runtime/UserQueryRoles.php · 91 lines

A user query's roles and capabilities as the meta clauses the reference writes for them (probe wp-user-query-sql): a capability matches its own name or any role granting it, capability__in and __not_in widen the role lists, and each role is a LIKE on the site's capabilities meta (NOT LIKE to leave it out).

Constants and properties

privatereadonly string $capabilitiesKey

Promoted from the constructor.

Public

new__construct(string $capabilitiesKey)#
methodclauses(array $qv, array $queries, array $roles): array#

The meta query's clauses once the roles and capabilities join them.

$qvarray<string, mixed>
$queriesarray<array-key, mixed>the meta query's own clauses
$rolesarray<string, array{capabilities: array<string, bool>}>the site's roles
@return array<array-key, mixed>

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatelists(array $qv, array $roles): array#

The roles asked for, the role__in and role__not_in lists (widened by the roles granting capability__in and __not_in, then the capabilities themselves), and the roles granting each capability asked for.

$qvarray<string, mixed>
$rolesarray<string, array{capabilities: array<string, bool>}>
@return array{0: array{roles: list<string>, capabilities: list<string>}, 1: list<string>, 2: list<string>, 3: array<string, list<string>>}
privatefirstOf(array $wanted, array $granted): ?string#

The first of the wanted capabilities a role grants, in the order asked. @param list<string> $wanted @param list<string> $granted

$wantedlist<string>@param list<string> $granted
privatelike(string $role, string $compare = 'LIKE'): array#
@return array<string, string>