TcaSelectItems extends AbstractItemProvider implements FormDataProviderInterface

Resolve select items, set processed item list in processedTca, sanitize and resolve database field

Table of Contents

Interfaces

FormDataProviderInterface
Interface must be implemented by form data provider classes.

Methods

addData()  : array<string|int, mixed>
Resolve select items
addIconFromAltIcons()  : array<string|int, mixed>
Add alternative icon using "altIcons" TSconfig
addInvalidItemsFromDatabase()  : array<string|int, mixed>
Add values that are currently listed in the database columns but not in the selectable items list back to the list.
sanitizeItemArray()  : array<string|int, mixed>
Sanitize incoming item array
translateLabels()  : array<string|int, mixed>
Translate the item labels
addItemsFromFolder()  : array<string|int, mixed>
TCA config "fileFolder" evaluation. Add them to $items
addItemsFromForeignTable()  : array<string|int, mixed>
TCA config "foreign_table" evaluation. Add them to $items
addItemsFromPageTsConfig()  : array<string|int, mixed>
Page TSconfig addItems:
buildForeignTableQueryBuilder()  : QueryBuilder
Build query to fetch foreign records. Helper method of addItemsFromForeignTable(), do not call otherwise.
getBackendUser()  : BackendUserAuthentication
getLanguageService()  : LanguageService
getLiveUid()  : int|string
Gets the record uid of the live default record. If already pointing to the live record, the submitted record uid is returned.
groupAndSortItems()  : array<string|int, mixed>
Is used when --div-- elements in the item list are used, or if groups are defined via "groupItems" config array.
isTargetRenderType()  : bool
Determines whether the current field is a valid target for this DataProvider
parseSiteConfiguration()  : array<string|int, mixed>
Parse ###SITE:### placeholders in the input string and return the replacements array for later use in $this->replaceParsedSiteConfiguration().
parseStartingPointsFromSiteConfiguration()  : array<string|int, mixed>
A field's [treeConfig][startingPoints] can be set via site config, parse possibly set values
processDatabaseFieldValue()  : array<string|int, mixed>
Convert the current database values into an array
processForeignTableClause()  : array<string|int, mixed>
Replace markers in a where clause from TCA foreign_table_where
processSelectFieldValue()  : array<string|int, mixed>
Validate and sanitize database row values of the select field with the given name.
quoteParsedSiteConfiguration()  : array<string|int, mixed>
removeItemsByDoktypeUserRestriction()  : array<string|int, mixed>
Remove items if doktype is handled for non admin users
removeItemsByKeepItemsPageTsConfig()  : array<string|int, mixed>
Remove items using "keepItems" pageTsConfig
removeItemsByRemoveItemsPageTsConfig()  : array<string|int, mixed>
Remove items using "removeItems" pageTsConfig
removeItemsByUserAuthMode()  : array<string|int, mixed>
Remove items by user restriction on authMode items
removeItemsByUserLanguageFieldRestriction()  : array<string|int, mixed>
Remove items user restriction on language field
removeItemsByUserStorageRestriction()  : array<string|int, mixed>
Remove items if sys_file_storage is not allowed for non-admin users.
replaceParsedSiteConfiguration()  : string
resolveItemProcessorFunction()  : array<string|int, mixed>
Resolve "itemProcFunc" of elements.
sortItems()  : array<string|int, mixed>
Sort given items by label or value or a custom user function built like "MyVendor\MyExtension\TcaSorter->sortItems" or a callable.

Methods

addData()

Resolve select items

public addData(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>

Initialized result array

Tags
throws
UnexpectedValueException
Return values
array<string|int, mixed>

addIconFromAltIcons()

Add alternative icon using "altIcons" TSconfig

public addIconFromAltIcons(array<string|int, mixed> $result, array<string|int, mixed> $items, string $table, string $fieldName) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>
$items : array<string|int, mixed>
$table : string
$fieldName : string
Return values
array<string|int, mixed>

addInvalidItemsFromDatabase()

Add values that are currently listed in the database columns but not in the selectable items list back to the list.

public addInvalidItemsFromDatabase(array<string|int, mixed> $result, string $table, string $fieldName, array<string|int, mixed> $fieldConf, array<string|int, mixed> $databaseValues, array<string|int, mixed> $removedItems) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>

The current result array.

$table : string

The current table name

$fieldName : string

The current field name

$fieldConf : array<string|int, mixed>

The configuration of the current field.

$databaseValues : array<string|int, mixed>

The item values from the database, can contain invalid items!

$removedItems : array<string|int, mixed>

Items removed by access checks and restrictions, must not be added as invalid values

Return values
array<string|int, mixed>

sanitizeItemArray()

Sanitize incoming item array

public sanitizeItemArray(mixed $itemArray, string $tableName, string $fieldName) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

Parameters
$itemArray : mixed
$tableName : string
$fieldName : string
Tags
throws
UnexpectedValueException
Return values
array<string|int, mixed>

translateLabels()

Translate the item labels

public translateLabels(array<string|int, mixed> $result, array<string|int, mixed> $itemArray, string $table, string $fieldName) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$itemArray : array<string|int, mixed>

Items

$table : string
$fieldName : string
Return values
array<string|int, mixed>

addItemsFromFolder()

TCA config "fileFolder" evaluation. Add them to $items

protected addItemsFromFolder(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

Modified item array

addItemsFromForeignTable()

TCA config "foreign_table" evaluation. Add them to $items

protected addItemsFromForeignTable(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items[, bool $includeFullRows = false ]) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handled field name

$items : array<string|int, mixed>

Incoming items

$includeFullRows : bool = false

@internal Hack for category tree to speed up tree processing, adding full db row as _row to item

Tags
throws
UnexpectedValueException
Return values
array<string|int, mixed>

Modified item array

addItemsFromPageTsConfig()

Page TSconfig addItems:

protected addItemsFromPageTsConfig(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

TCEFORMS.aTable.aField[.types][.aType].addItems.aValue = aLabel, with type specific options merged by pageTsConfig already

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

buildForeignTableQueryBuilder()

Build query to fetch foreign records. Helper method of addItemsFromForeignTable(), do not call otherwise.

protected buildForeignTableQueryBuilder(array<string|int, mixed> $result, string $localFieldName[, bool $selectAllFields = false ]) : QueryBuilder
Parameters
$result : array<string|int, mixed>

Result array

$localFieldName : string

Current handle field name

$selectAllFields : bool = false

@internal True to select * all fields of row, otherwise an auto-calculated list. Select * is an optimization hack to speed up category tree calculation.

Return values
QueryBuilder

getLiveUid()

Gets the record uid of the live default record. If already pointing to the live record, the submitted record uid is returned.

protected getLiveUid(array<string|int, mixed> $result) : int|string
Parameters
$result : array<string|int, mixed>

Result array

Tags
throws
UnexpectedValueException
Return values
int|string

If the record is new, uid will be a string beginning with "NEW". Otherwise an int.

groupAndSortItems()

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

protected groupAndSortItems(array<string|int, mixed> $allItems, array<string|int, mixed> $definedGroups, array<string|int, mixed> $sortOrders) : array<string|int, mixed>

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
$allItems : array<string|int, mixed>

all resolved items including the ones from foreign_table values. The group ID information can be found in key ['group'] of an item.

$definedGroups : array<string|int, mixed>

[config][itemGroups]

$sortOrders : array<string|int, mixed>

[config][sortOrders]

Return values
array<string|int, mixed>

isTargetRenderType()

Determines whether the current field is a valid target for this DataProvider

protected isTargetRenderType(array<string|int, mixed> $fieldConfig) : bool
Parameters
$fieldConfig : array<string|int, mixed>
Return values
bool

parseSiteConfiguration()

Parse ###SITE:### placeholders in the input string and return the replacements array for later use in $this->replaceParsedSiteConfiguration().

protected parseSiteConfiguration(SiteInterface|null $site, string $input) : array<string|int, mixed>

IMPORTANT: If the values are used within raw SQL statements (e.g. foreign_table_where), consider using $this->quoteParsedSiteConfiguration() before replacement.

Parameters
$site : SiteInterface|null
$input : string
Return values
array<string|int, mixed>

parseStartingPointsFromSiteConfiguration()

A field's [treeConfig][startingPoints] can be set via site config, parse possibly set values

protected parseStartingPointsFromSiteConfiguration(array<string|int, mixed> $result, array<string|int, mixed> $fieldConfig) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>
$fieldConfig : array<string|int, mixed>
Return values
array<string|int, mixed>

processDatabaseFieldValue()

Convert the current database values into an array

protected processDatabaseFieldValue(array<string|int, mixed> $row, string $fieldName) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>

database row

$fieldName : string

fieldname to process

Return values
array<string|int, mixed>

processForeignTableClause()

Replace markers in a where clause from TCA foreign_table_where

protected processForeignTableClause(array<string|int, mixed> $result, string $foreignTableName, string $localFieldName) : array<string|int, mixed>

###REC_FIELD_[field name]### ###THIS_UID### - is current element uid (zero if new). ###CURRENT_PID### - is the current page id (pid of the record). ###SITEROOT### ###PAGE_TSCONFIG_ID### - a value you can set from page TSconfig dynamically. ###PAGE_TSCONFIG_IDLIST### - a value you can set from page TSconfig dynamically. ###PAGE_TSCONFIG_STR### - a value you can set from page TSconfig dynamically.

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

Result array

$foreignTableName : string

Name of foreign table

$localFieldName : string

Current handle field name

Return values
array<string|int, mixed>

Query parts with keys WHERE, ORDERBY, GROUPBY, LIMIT

processSelectFieldValue()

Validate and sanitize database row values of the select field with the given name.

protected processSelectFieldValue(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $staticValues) : array<string|int, mixed>

Creates an array out of databaseRow[selectField] values.

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

The current result array.

$fieldName : string

Name of the current select field.

$staticValues : array<string|int, mixed>

Array with statically defined items, item value is used as array key.

Return values
array<string|int, mixed>

quoteParsedSiteConfiguration()

protected quoteParsedSiteConfiguration(Connection $connection, array<string|int, mixed> $parsedSiteConfiguration) : array<string|int, mixed>
Parameters
$connection : Connection
$parsedSiteConfiguration : array<string|int, mixed>
Return values
array<string|int, mixed>

removeItemsByDoktypeUserRestriction()

Remove items if doktype is handled for non admin users

protected removeItemsByDoktypeUserRestriction(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

removeItemsByKeepItemsPageTsConfig()

Remove items using "keepItems" pageTsConfig

protected removeItemsByKeepItemsPageTsConfig(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

removeItemsByRemoveItemsPageTsConfig()

Remove items using "removeItems" pageTsConfig

protected removeItemsByRemoveItemsPageTsConfig(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

removeItemsByUserAuthMode()

Remove items by user restriction on authMode items

protected removeItemsByUserAuthMode(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

removeItemsByUserLanguageFieldRestriction()

Remove items user restriction on language field

protected removeItemsByUserLanguageFieldRestriction(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems and TcaSelectTreeItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

removeItemsByUserStorageRestriction()

Remove items if sys_file_storage is not allowed for non-admin users.

protected removeItemsByUserStorageRestriction(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>

Used by TcaSelectItems data providers

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

Result array

$fieldName : string

Current handle field name

$items : array<string|int, mixed>

Incoming items

Return values
array<string|int, mixed>

Modified item array

replaceParsedSiteConfiguration()

protected replaceParsedSiteConfiguration(string $input, array<string|int, mixed> $parsedSiteConfiguration) : string
Parameters
$input : string
$parsedSiteConfiguration : array<string|int, mixed>
Return values
string

resolveItemProcessorFunction()

Resolve "itemProcFunc" of elements.

protected resolveItemProcessorFunction(array<string|int, mixed> $result, string $fieldName, array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>

Main result array

$fieldName : string

Field name to handle item list for

$items : array<string|int, mixed>

Existing items array

Return values
array<string|int, mixed>

New list of item elements

sortItems()

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

protected sortItems(array<string|int, mixed> $items, array<string|int, mixed> $sortOrders) : array<string|int, mixed>
Parameters
$items : array<string|int, mixed>
$sortOrders : array<string|int, mixed>

should be something like like [label => desc]

Return values
array<string|int, mixed>

the sorted items


        
On this page

Search results