‪TYPO3CMS  ‪main
TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor Class Reference

Public Member Functions

 __construct (protected readonly LanguageServiceFactory $languageServiceFactory)
 
 groupAndSortItems (array $allItems, array $definedGroups, array $sortOrders)
 
SelectItem[] transformArrayToSelectItems (array $items, string $type='select')
 
 transformSelectItemsToArray (array $items)
 

Protected Member Functions

SelectItem[] sortItems (array $items, array $sortOrders)
 

Private Member Functions

 getLanguageService ()
 
 getBackendUser ()
 

Detailed Description

Provides shared select item related utility functions.

ext:backend internal implementation and not part of the public core API.

Todo:
‪Move additional shareable code from form-engine into here.

Definition at line 32 of file SelectItemProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::__construct ( protected readonly LanguageServiceFactory  $languageServiceFactory)

Definition at line 34 of file SelectItemProcessor.php.

Member Function Documentation

◆ getBackendUser()

TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::getBackendUser ( )
private

◆ getLanguageService()

TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::getLanguageService ( )
private

◆ groupAndSortItems()

TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::groupAndSortItems ( array  $allItems,
array  $definedGroups,
array  $sortOrders 
)

Is used when –div– elements in the item list are used, or if groups are defined via "groupItems" config array.

This method takes the –div– elements out of the list, and adds them to the group lists.

A main "none" group is added, which is always on top, when items are not set to be in a group. All items without a groupId - which is defined by the fourth key of an item in the item array - are added to the "none" group, or to the last group used previously, to ensure ordering as much as possible as before.

Then the found groups are iterated over the order in the [itemGroups] list, and items within a group can be sorted via "sortOrders" configuration.

All grouped items are then "flattened" out and –div– items are added for each group to keep backwards-compatibility.

Parameters
array$allItems‪all resolved items including the ones from foreign_table values. The group ID information can be found in key ['group'] of an item.
array$definedGroups‪[config][itemGroups]
array$sortOrders‪[config][sortOrders]

Definition at line 54 of file SelectItemProcessor.php.

References TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor\getLanguageService(), TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor\sortItems(), TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor\transformArrayToSelectItems(), and TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor\transformSelectItemsToArray().

◆ sortItems()

SelectItem [] TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::sortItems ( array  $items,
array  $sortOrders 
)
protected

Sort given items by label or value or a custom user function built like "MyVendor\MyExtension\TcaSorter->sortItems" or a callable.

Parameters
SelectItem[]$items
array$sortOrders‪should be something like like [label => desc]
Returns
‪SelectItem[] the sorted items

Definition at line 157 of file SelectItemProcessor.php.

References TYPO3\CMS\Core\Schema\Struct\SelectItem\getLabel(), and TYPO3\CMS\Core\Schema\Struct\SelectItem\getValue().

Referenced by TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor\groupAndSortItems().

◆ transformArrayToSelectItems()

SelectItem [] TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::transformArrayToSelectItems ( array  $items,
string  $type = 'select' 
)

◆ transformSelectItemsToArray()

TYPO3\CMS\Backend\Form\Processor\SelectItemProcessor::transformSelectItemsToArray ( array  $items)