‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Authentication\GroupResolver Class Reference

Public Member Functions

 __construct (EventDispatcherInterface $eventDispatcher)
 
array resolveGroupsForUser (array $userRecord, string $sourceTable)
 
array findAllUsersInGroups (array $groupIds, string $sourceTable, string $userSourceTable)
 

Protected Member Functions

 fetchGroupsRecursive (array $groupIds, array $processedGroupIds=[])
 
array fetchRowsFromDatabase (array $groupIds)
 
array fetchParentGroupsRecursive (array $groupIds, array $processedGroupIds=[])
 
 fetchParentGroupsFromDatabase (array $subgroupIds)
 

Protected Attributes

EventDispatcherInterface $eventDispatcher
 
string $sourceTable = ''
 
string $sourceField = 'usergroup'
 
string $recursiveSourceField = 'subgroup'
 

Detailed Description

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.

this is not part of TYPO3 Core API.

Definition at line 37 of file GroupResolver.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Authentication\GroupResolver::__construct ( EventDispatcherInterface  $eventDispatcher)

Member Function Documentation

◆ fetchGroupsRecursive()

TYPO3\CMS\Core\Authentication\GroupResolver::fetchGroupsRecursive ( array  $groupIds,
array  $processedGroupIds = [] 
)
protected

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

Parameters
int[]$groupIds

Definition at line 74 of file GroupResolver.php.

References TYPO3\CMS\Core\Authentication\GroupResolver\fetchRowsFromDatabase(), and TYPO3\CMS\Core\Utility\GeneralUtility\intExplode().

Referenced by TYPO3\CMS\Core\Authentication\GroupResolver\resolveGroupsForUser().

◆ fetchParentGroupsFromDatabase()

TYPO3\CMS\Core\Authentication\GroupResolver::fetchParentGroupsFromDatabase ( array  $subgroupIds)
protected

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

Definition at line 205 of file GroupResolver.php.

Referenced by TYPO3\CMS\Core\Authentication\GroupResolver\fetchParentGroupsRecursive().

◆ fetchParentGroupsRecursive()

array TYPO3\CMS\Core\Authentication\GroupResolver::fetchParentGroupsRecursive ( array  $groupIds,
array  $processedGroupIds = [] 
)
protected

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

Parameters
int[]$groupIds‪a list of groups to find THEIR ancestors
array$processedGroupIds‪helper function to avoid recursive detection
Returns
‪array a list of parent groups and thus, grand grand parent groups as well

Definition at line 180 of file GroupResolver.php.

References TYPO3\CMS\Core\Authentication\GroupResolver\fetchParentGroupsFromDatabase().

Referenced by TYPO3\CMS\Core\Authentication\GroupResolver\findAllUsersInGroups().

◆ fetchRowsFromDatabase()

array TYPO3\CMS\Core\Authentication\GroupResolver::fetchRowsFromDatabase ( array  $groupIds)
protected

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

Returns
‪array Full records with record uid as key

Definition at line 107 of file GroupResolver.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_INT_ARRAY.

Referenced by TYPO3\CMS\Core\Authentication\GroupResolver\fetchGroupsRecursive(), and TYPO3\CMS\Core\Authentication\GroupResolver\findAllUsersInGroups().

◆ findAllUsersInGroups()

array TYPO3\CMS\Core\Authentication\GroupResolver::findAllUsersInGroups ( array  $groupIds,
string  $sourceTable,
string  $userSourceTable 
)

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.

Parameters
int[]$groupIds‪a list of IDs of groups
string$sourceTable‪e.g. be_groups or fe_groups
string$userSourceTable‪e.g. be_users or fe_users
Returns
‪array full user records

Definition at line 140 of file GroupResolver.php.

References TYPO3\CMS\Core\Authentication\GroupResolver\$sourceTable, TYPO3\CMS\Core\Authentication\GroupResolver\fetchParentGroupsRecursive(), and TYPO3\CMS\Core\Authentication\GroupResolver\fetchRowsFromDatabase().

◆ resolveGroupsForUser()

array TYPO3\CMS\Core\Authentication\GroupResolver::resolveGroupsForUser ( array  $userRecord,
string  $sourceTable 
)

Fetch all group records for a given user recursive.

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
array$userRecord‪Used for context in PSR-14 event
string$sourceTable‪The database table to look up: be_groups / fe_groups depending on context
Returns
‪array List of group records. Note the ordering note above.

Definition at line 60 of file GroupResolver.php.

References TYPO3\CMS\Core\Authentication\GroupResolver\$sourceTable, TYPO3\CMS\Core\Authentication\GroupResolver\fetchGroupsRecursive(), and TYPO3\CMS\Core\Utility\GeneralUtility\intExplode().

Member Data Documentation

◆ $eventDispatcher

EventDispatcherInterface TYPO3\CMS\Core\Authentication\GroupResolver::$eventDispatcher
protected

◆ $recursiveSourceField

string TYPO3\CMS\Core\Authentication\GroupResolver::$recursiveSourceField = 'subgroup'
protected

Definition at line 42 of file GroupResolver.php.

◆ $sourceField

string TYPO3\CMS\Core\Authentication\GroupResolver::$sourceField = 'usergroup'
protected

Definition at line 41 of file GroupResolver.php.

◆ $sourceTable

string TYPO3\CMS\Core\Authentication\GroupResolver::$sourceTable = ''
protected