final class DbUserGroupRepository implements UserGroupRepositoryInterface (View source)

SQL persistence for user groups in the user_groups table, with member and zone counts.

Methods

__construct(PDO $db)

No description

array
findAll()

Find all groups

array
findByUserId(int $userId)

Find groups by user ID (groups the user belongs to)

array
findByUserIds(array $userIds)

No description

array
getGroupIdsForUser(int $userId)

Get the IDs of the groups the user belongs to

UserGroup|null
findById(int $id)

Find a group by ID

UserGroup|null
findByName(string $name)

Find a group by name

int|null
findIdByExactName(string $name)

Id of the group with exactly this name, accent-exact so an IdP-asserted claim cannot map to a look-alike group.

array
findExistingIds(array $ids)

Return the subset of supplied IDs that actually exist in user_groups.

save(UserGroup $group)

Save (create or update) a group

bool
delete(int $id)

Delete a group by ID

int
countAll()

Count all groups

array
getMemberCountsByGroupIds(array $groupIds)

Get member counts for multiple groups in a single query

int
countMembers(int $groupId)

Count members in a group

int
countZones(int $groupId)

Count zones owned by a group

void
lockForZoneLimit(int $groupId)

Lock the group's row until the open transaction ends, so zone limit checks for this group run one at a time

bool
setZoneLimit(int $groupId, int|null $limit)

Set the group's own zone limit; null removes it so the configured default applies

Details

__construct(PDO $db)

No description

Parameters

PDO $db

array findAll()

Find all groups

Return Value

array

array findByUserId(int $userId)

Find groups by user ID (groups the user belongs to)

Parameters

int $userId

Return Value

array

array findByUserIds(array $userIds)

No description

Parameters

array $userIds

Return Value

array

Keyed by user ID; users with no groups are absent

array getGroupIdsForUser(int $userId)

Get the IDs of the groups the user belongs to

Parameters

int $userId

Return Value

array

UserGroup|null findById(int $id)

Find a group by ID

Parameters

int $id

Return Value

UserGroup|null

UserGroup|null findByName(string $name)

Find a group by name

Parameters

string $name

Return Value

UserGroup|null

int|null findIdByExactName(string $name)

Id of the group with exactly this name, accent-exact so an IdP-asserted claim cannot map to a look-alike group.

Parameters

string $name

Return Value

int|null

array findExistingIds(array $ids)

Return the subset of supplied IDs that actually exist in user_groups.

Parameters

array $ids

Return Value

array

UserGroup save(UserGroup $group)

Save (create or update) a group

Parameters

UserGroup $group

Return Value

UserGroup

bool delete(int $id)

Delete a group by ID

Parameters

int $id

Return Value

bool

int countAll()

Count all groups

Return Value

int

array getMemberCountsByGroupIds(array $groupIds)

Get member counts for multiple groups in a single query

Parameters

array $groupIds

Return Value

array

Map of group_id => member_count

int countMembers(int $groupId)

Count members in a group

Parameters

int $groupId

Return Value

int

int countZones(int $groupId)

Count zones owned by a group

Parameters

int $groupId

Return Value

int

void lockForZoneLimit(int $groupId)

Lock the group's row until the open transaction ends, so zone limit checks for this group run one at a time

Parameters

int $groupId

Return Value

void

bool setZoneLimit(int $groupId, int|null $limit)

Set the group's own zone limit; null removes it so the configured default applies

Parameters

int $groupId
int|null $limit

Return Value

bool