GroupResolver
class \
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.
Table of Contents
Properties
- $eventDispatcher : EventDispatcherInterface
- $recursiveSourceField : string
- $sourceField : string
- $sourceTable : string
Methods
- __construct() : mixed
- findAllUsersInGroups() : array
- 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
- Fetch all group records for a given user recursive.
- fetchGroupsRecursive() : array
- Load a list of group uids, and take into account if groups have been loaded before.
- fetchParentGroupsFromDatabase() : array
- Find all groups that have a FIND_IN_SET(subgroups, [$subgroupIds]) => the parent groups via one SQL query.
- fetchParentGroupsRecursive() : array
- Load a list of group uids, and take into account if groups have been loaded before as part of recursive detection.
- fetchRowsFromDatabase() : array
- 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(int[] $groupIds, string $sourceTable, string $userSourceTable) : array
Parameters
- $groupIds : 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 —full user records
resolveGroupsForUser()
Fetch all group records for a given user recursive.
public
resolveGroupsForUser(array $userRecord, string $sourceTable) : array
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
-
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 —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(int[] $groupIds[, array $processedGroupIds = [] ]) : array
Parameters
- $groupIds : int[]
- $processedGroupIds : array = []
Return values
arrayfetchParentGroupsFromDatabase()
Find all groups that have a FIND_IN_SET(subgroups, [$subgroupIds]) => the parent groups via one SQL query.
protected
fetchParentGroupsFromDatabase(array $subgroupIds) : array
Parameters
- $subgroupIds : array
Return values
arrayfetchParentGroupsRecursive()
Load a list of group uids, and take into account if groups have been loaded before as part of recursive detection.
protected
fetchParentGroupsRecursive(int[] $groupIds[, array $processedGroupIds = [] ]) : array
Parameters
- $groupIds : int[]
-
a list of groups to find THEIR ancestors
- $processedGroupIds : array = []
-
helper function to avoid recursive detection
Return values
array —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 $groupIds) : array
Parameters
- $groupIds : array
Return values
array —Full records with record uid as key