GroupResolver

A provider for resolving fe_groups / be_groups, including nested sub groups.

When fetching subgroups, the current group (parent group) is handed in recursive. Duplicates are suppressed: If a subgroup is including in multiple parent groups, it will be resolved only once.

Internal

this is not part of TYPO3 Core API.

Attributes
#[Autoconfigure]
$public: true
$shared: false

Table of Contents

Properties

$eventDispatcher  : EventDispatcherInterface
$recursiveSourceField  : string
$sourceField  : string
$sourceTable  : string

Methods

__construct()  : mixed
findAllUsersInGroups()  : array<string|int, mixed>
This works the other way around: Find all users that belong to some groups. Because groups are nested, we need to find all groups and subgroups first, because maybe a user is only part of a higher group, instead of a "All editors" group.
resolveGroupsForUser()  : array<string|int, mixed>
Fetch all group records for a given user recursive.
fetchGroupsRecursive()  : array<string|int, mixed>
Load a list of group uids, and take into account if groups have been loaded before.
fetchParentGroupsFromDatabase()  : array<string|int, mixed>
Find all groups that have a FIND_IN_SET(subgroups, [$subgroupIds]) => the parent groups via one SQL query.
fetchParentGroupsRecursive()  : array<string|int, mixed>
Load a list of group uids, and take into account if groups have been loaded before as part of recursive detection.
fetchRowsFromDatabase()  : array<string|int, mixed>
Does the database query. Does not care about ordering, this is done by caller.

Properties

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

$recursiveSourceField

protected string $recursiveSourceField = 'subgroup'

$sourceField

protected string $sourceField = 'usergroup'

$sourceTable

protected string $sourceTable = ''

Methods

__construct()

public __construct(EventDispatcherInterface $eventDispatcher) : mixed
Parameters
$eventDispatcher : EventDispatcherInterface

findAllUsersInGroups()

This works the other way around: Find all users that belong to some groups. Because groups are nested, we need to find all groups and subgroups first, because maybe a user is only part of a higher group, instead of a "All editors" group.

public findAllUsersInGroups(array<string|int, int> $groupIds, string $sourceTable, string $userSourceTable) : array<string|int, mixed>
Parameters
$groupIds : array<string|int, int>

a list of IDs of groups

$sourceTable : string

e.g. be_groups or fe_groups

$userSourceTable : string

e.g. be_users or fe_users

Return values
array<string|int, mixed>

full user records

resolveGroupsForUser()

Fetch all group records for a given user recursive.

public resolveGroupsForUser(array<string|int, mixed> $userRecord, string $sourceTable) : array<string|int, mixed>

Note order is important: A user with main groups "1,2", where 1 has sub group 3, results in "3,1,2" as record list array - sub groups are listed before the group that includes the sub group.

Parameters
$userRecord : array<string|int, mixed>

Used for context in PSR-14 event

$sourceTable : string

The database table to look up: be_groups / fe_groups depending on context

Return values
array<string|int, mixed>

List of group records. Note the ordering note above.

fetchGroupsRecursive()

Load a list of group uids, and take into account if groups have been loaded before.

protected fetchGroupsRecursive(array<string|int, int> $groupIds[, array<string|int, mixed> $processedGroupIds = [] ]) : array<string|int, mixed>
Parameters
$groupIds : array<string|int, int>
$processedGroupIds : array<string|int, mixed> = []
Return values
array<string|int, mixed>

fetchParentGroupsFromDatabase()

Find all groups that have a FIND_IN_SET(subgroups, [$subgroupIds]) => the parent groups via one SQL query.

protected fetchParentGroupsFromDatabase(array<string|int, mixed> $subgroupIds) : array<string|int, mixed>
Parameters
$subgroupIds : array<string|int, mixed>
Return values
array<string|int, mixed>

fetchParentGroupsRecursive()

Load a list of group uids, and take into account if groups have been loaded before as part of recursive detection.

protected fetchParentGroupsRecursive(array<string|int, int> $groupIds[, array<string|int, mixed> $processedGroupIds = [] ]) : array<string|int, mixed>
Parameters
$groupIds : array<string|int, int>

a list of groups to find THEIR ancestors

$processedGroupIds : array<string|int, mixed> = []

helper function to avoid recursive detection

Return values
array<string|int, mixed>

a list of parent groups and thus, grand grand parent groups as well

fetchRowsFromDatabase()

Does the database query. Does not care about ordering, this is done by caller.

protected fetchRowsFromDatabase(array<string|int, mixed> $groupIds) : array<string|int, mixed>
Parameters
$groupIds : array<string|int, mixed>
Return values
array<string|int, mixed>

Full records with record uid as key


        
On this page

Search results