GroupResolver
readonly 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.
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Methods
- __construct() : mixed
- findAllParentGroupIds() : int[]
- Find the uids of all groups which include one of the given groups as subgroup, recursively. Members of these groups inherit the given groups.
- 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.
Methods
__construct()
public
__construct(EventDispatcherInterface $eventDispatcher, ConnectionPool $connectionPool) : mixed
Parameters
- $eventDispatcher : EventDispatcherInterface
- $connectionPool : ConnectionPool
findAllParentGroupIds()
Find the uids of all groups which include one of the given groups as subgroup, recursively. Members of these groups inherit the given groups.
public
findAllParentGroupIds(int[] $groupIds, string $sourceTable) : int[]
Parameters
- $groupIds : int[]
- $sourceTable : string
-
e.g. be_groups or fe_groups
Return values
int[] —uids of the including groups, without the given groups
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(string $sourceTable, int[] $groupIds[, array $processedGroupIds = [] ]) : array
Parameters
- $sourceTable : string
- $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(string $sourceTable, array $subgroupIds) : array
Parameters
- $sourceTable : string
- $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(string $sourceTable, int[] $groupIds[, array $processedGroupIds = [] ]) : array
Parameters
- $sourceTable : string
- $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(string $sourceTable, array $groupIds) : array
Parameters
- $sourceTable : string
- $groupIds : array
Return values
array —Full records with record uid as key