BackendUtility

Standard functions available for the TYPO3 backend.

You are encouraged to use this class in your own applications (Backend Modules) Don't instantiate - call functions with "\TYPO3\CMS\Backend\Utility\BackendUtility::" prefixed the function name.

Call ALL methods without making an object! Eg. to get a page-record 51 do this: '\TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages',51)'

Table of Contents

Methods

BEenableFields()  : string
Backend implementation of enableFields() Notice that "fe_groups" is not selected for - only disabled, starttime and endtime.
BEgetRootLine()  : array<string|int, mixed>
Returns what is called the 'RootLine'. That is an array with information about the page records from a page id ($uid) and back to the root.
calcAge()  : string
Returns the "age" in minutes / hours / days / years of the number of $seconds inputted.
convertDatabaseRowValuesToPhp()  : array<string|int, mixed>
Gets the raw database row values and calls the php converter of doctrine to get the PHP value.
date()  : string
Returns $tstamp formatted as "ddmmyy" (According to $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'])
datetime()  : string
Returns $tstamp formatted as "ddmmyy hhmm" (According to $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] AND $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'])
dateTimeAge()  : string
Returns a formatted timestamp if $tstamp is set.
daysUntil()  : int
Returns the difference in days between input $tstamp and $EXEC_TIME
getAllowedFieldsForTable()  : array<string|int, string>
Get all fields of a table, which are allowed for the current user
getCommonSelectFields()  : string
Returns fields for a table, $table, which would typically be interesting to select This includes uid, the fields defined for title, icon-field.
getContextMenuAttributes()  : array<string|int, mixed>
getExistingPageTranslations()  : array<string|int, mixed>
Fetch all records of the given page ID.
getGroupNames()  : array<string|int, mixed>
Returns an array with be_groups records (title, uid) of all groups NOT DELETED sorted by their title
getItemLabel()  : string|null
Returns the label-value for fieldname $column in table $table.
getLabelFromItemlist()  : string
Returns the label of the first found entry in an "items" array from $GLOBALS['TCA'] (tablename = $table/fieldname = $col) where the value is $key
getLabelFromItemListMerged()  : string
Return the label of a field by additionally checking TsConfig values
getLabelsFromItemsList()  : string
Splits the given key with commas and returns the list of all the localized items labels, separated by a comma.
getLiveVersionIdOfRecord()  : int|null
Gets the id of the live version of a record.
getLiveVersionOfRecord()  : array<string|int, mixed>|null
Returns live version of record
getModuleData()  : array<string|int, mixed>
Returns an array which is most backend modules becomes MOD_SETTINGS containing values from function menus etc. determining the function of the module.
getNoRecordTitle()  : string
Get a localized [No title] string, wrapped in <em>|</em> if $prep is TRUE.
getPagesTSconfig()  : array<string|int, mixed>
Returns the page TSconfig for page with uid $pageUid.
getPossibleWorkspaceVersionIdsOfLiveRecordIds()  : array<int, int>
Use this function if you have a large set of IDs to find out which ones have a counterpart within a workspace.
getProcessedValue()  : string|null
Returns a human readable output of a value from a record For instance a database record relation would be looked up to display the title-value of that record. A checkbox with a "1" value would be "Yes", etc.
getProcessedValueExtra()  : string
Same as ->getProcessedValue() but will go easy on fields like "tstamp" and "pid" which are not configured in TCA - they will be formatted by this function instead.
getRecord()  : array<string|int, mixed>|null
Gets record with uid = $uid from $table You can set $field to a list of fields (default is '*') Additional WHERE clauses can be added by $where (fx. ' AND some_field = 1') Will automatically check if records has been deleted and if so, not return anything.
getRecordIconAltText()  : string
Returns title-attribute information for ANY record (from a table defined in TCA of course) The included information depends on features of the table, but if hidden, starttime, endtime and fe_group fields are configured for, information about the record status in regard to these features are is included.
getRecordLocalization()  : mixed
Fetches the localization for a given record.
getRecordPath()  : mixed
Returns the path (visually) of a page $uid, fx. "/First page/Second page/Another subpage" Each part of the path will be limited to $titleLimit characters Deleted pages are filtered out.
getRecordTitle()  : string
Returns the "title"-value in record, $row, from table, $table The field(s) from which the value is taken is determined by the "ctrl"-entries 'label', 'label_alt' and 'label_alt_force'
getRecordTitlePrep()  : string
Crops a title string to a limited length and if it really was cropped, wrap it in a <span title="...">|</span>, which offers a tooltip with the original title when moving mouse over it.
getRecordWSOL()  : array<string|int, mixed>|null
Like getRecord(), but overlays workspace version if any.
getTCAtypeValue()  : string
Returns the "type" value of $rec from $table which can be used to look up the correct "types" rendering section in $GLOBALS['TCA'] If no "type" field is configured in the "ctrl"-section of the $GLOBALS['TCA'] for the table, zero is used.
getTCEFORM_TSconfig()  : array<string|int, mixed>
Returns TSConfig for the TCEFORM object in page TSconfig.
getTSconfig_pidValue()  : int|null
Find the real PID of the record (with $uid from $table).
getTSCpid()  : array<string|int, mixed>
Returns the REAL pid of the record, if possible. If both $uid and $pid is strings, then pid=-1 is returned as an error indication.
getTSCpidCached()  : array<string|int, mixed>
Return the real pid of a record and caches the result.
getUpdateSignalDetails()  : array{html: list}
Gets instructions for update signals (e.g. page tree shall be refreshed, since some page title has been modified during the current HTTP request).
getUserNames()  : array<string|int, mixed>
Returns an array with be_users records of all user NOT DELETED sorted by their username Keys in the array is the be_users uid
getWorkspaceVersionOfRecord()  : array<string|int, mixed>|bool
Select the workspace version of a record, if exists
isRecordLocked()  : array<string|int, mixed>|bool
Returns information about whether the record from table, $table, with uid, $uid is currently locked (edited by another user - which should issue a warning).
isRootLevelRestrictionIgnored()  : bool
Whether to ignore restrictions on root-level records.
isTableLocalizable()  : bool
Determines whether a table is localizable and has the languageField and transOrigPointerField set in $GLOBALS['TCA'].
isTableWorkspaceEnabled()  : bool
Determines whether a table is enabled for workspaces.
isWebMountRestrictionIgnored()  : bool
Whether to ignore restrictions on a web-mount of a table.
lockRecords()  : mixed
Unlock or Lock a record from $table with $uid If $table and $uid is not set, then all locking for the current BE_USER is removed!
openPageTree()  : mixed
Opens the page tree to the specified page id
purgeComputedPropertiesFromRecord()  : array<string, mixed>
Purges computed properties starting with underscore character ('_').
purgeComputedPropertyNames()  : array<string|int, mixed>
Purges computed property names starting with underscore character ('_').
readPageAccess()  : array<string|int, mixed>|false
Returns a page record (of page with $id) with an extra field "_thePath" set to the record path if the WHERE clause $perms_clause selects the record. This works as an access check that returns a page record if access was granted, otherwise false.
referenceCount()  : string|int
Counting references to a record/file
resolveFileReferences()  : array<string|int, FileReference>|null
Resolves file references for a given record.
selectVersionsOfRecord()  : array<string|int, mixed>|null
Select all versions of a record, ordered by latest created version (uid DESC)
setUpdateSignal()  : mixed
Call to update the page tree frame (or something else..?) after use 'updatePageTree' as a first parameter will set the page tree to be updated.
splitTable_Uid()  : array<string|int, mixed>
Makes a backwards explode on the $str and returns an array with ($table, $uid).
time()  : string
Returns $value (in seconds) formatted as hh:mm:ss For instance $value = 3600 + 60*2 + 3 should return "01:02:03"
titleAttribForPages()  : string
Returns title-attribute information for a page-record informing about id, doktype, hidden, starttime, endtime, fe_group etc.
translationCount()  : string
Counting translations of records
workspaceOL()  : mixed
Workspace Preview Overlay.
wrapClickMenuOnIcon()  : string
Makes click menu link (context sensitive menu)
wsMapId()  : int
Performs mapping of new uids to new versions UID in case of import inside a workspace.
getBackendUserAuthentication()  : BackendUserAuthentication|null
getConnectionForTable()  : Connection
getLanguageService()  : LanguageService
getLogger()  : LoggerInterface
getPageForRootline()  : array<string|int, mixed>
Gets the cached page record for the rootline
getQueryBuilderForTable()  : QueryBuilder
getRecordsSortedByTitle()  : array<string|int, mixed>
Returns an array of all non-deleted records of a table sorted by a given title field.
getRuntimeCache()  : FrontendInterface
Gets an instance of the runtime cache.
resolveRelationLabels()  : array<string|int, mixed>
Helper method to fetch all labels for all relations of processed Values.

Methods

BEenableFields()

Backend implementation of enableFields() Notice that "fe_groups" is not selected for - only disabled, starttime and endtime.

public static BEenableFields(string $table[, bool $inv = false ]) : string

Notice that deleted-fields are NOT filtered - you must ALSO call deleteClause in addition. $GLOBALS["SIM_ACCESS_TIME"] is used for date.

Parameters
$table : string

The table from which to return enableFields WHERE clause. Table name must have a 'ctrl' section in $GLOBALS['TCA'].

$inv : bool = false

Means that the query will select all records NOT VISIBLE records (inverted selection)

Internal

should only be used from within TYPO3 Core, but DefaultRestrictionHandler is recommended as alternative

Return values
string

WHERE clause part

BEgetRootLine()

Returns what is called the 'RootLine'. That is an array with information about the page records from a page id ($uid) and back to the root.

public static BEgetRootLine(int $uid[, string $clause = '' ][, bool $workspaceOL = false ][, array<string|int, string> $additionalFields = [] ]) : array<string|int, mixed>

By default deleted pages are filtered. This RootLine will follow the tree all the way to the root. This is opposite to another kind of root line known from the frontend where the rootline stops when a root-template is found.

Parameters
$uid : int

Page id for which to create the root line.

$clause : string = ''

Clause can be used to select other criteria. It would typically be where-clauses that stops the process if we meet a page, the user has no reading access to.

$workspaceOL : bool = false

If TRUE, version overlay is applied. This must be requested specifically because it is usually only wanted when the rootline is used for visual output while for permission checking you want the raw thing!

$additionalFields : array<string|int, string> = []

Additional Fields to select for rootline records

Return values
array<string|int, mixed>

Root line array, all the way to the page tree root uid=0 (or as far as $clause allows!), including the page given as $uid

calcAge()

Returns the "age" in minutes / hours / days / years of the number of $seconds inputted.

public static calcAge(int $seconds[, string $labels = 'min|hrs|days|yrs|min|hour|day|year' ]) : string
Parameters
$seconds : int

Seconds could be the difference of a certain timestamp and time()

$labels : string = 'min|hrs|days|yrs|min|hour|day|year'

Labels should be something like ' min| hrs| days| yrs| min| hour| day| year'. This value is typically delivered by this function call: $GLOBALS["LANG"]->sL("LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears")

Return values
string

Formatted time

convertDatabaseRowValuesToPhp()

Gets the raw database row values and calls the php converter of doctrine to get the PHP value.

public static convertDatabaseRowValuesToPhp(string $table, array<string|int, mixed> $row) : array<string|int, mixed>

Currently only handles type=json and takes care of decoding the value.

Parameters
$table : string
$row : array<string|int, mixed>
Internal
Return values
array<string|int, mixed>

date()

Returns $tstamp formatted as "ddmmyy" (According to $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'])

public static date(int $tstamp) : string
Parameters
$tstamp : int

Time stamp, seconds

Return values
string

Formatted time

datetime()

Returns $tstamp formatted as "ddmmyy hhmm" (According to $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] AND $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'])

public static datetime(int $value) : string
Parameters
$value : int

Time stamp, seconds

Return values
string

Formatted time

dateTimeAge()

Returns a formatted timestamp if $tstamp is set.

public static dateTimeAge(int $tstamp[, int $prefix = 1 ][, string $date = '' ]) : string

The date/datetime will be followed by the age in parenthesis.

Parameters
$tstamp : int

Time stamp, seconds

$prefix : int = 1

1/-1 depending on polarity of age.

$date : string = ''

$date=="date" will yield "dd:mm:yy" formatting, otherwise "dd:mm:yy hh:mm

Return values
string

daysUntil()

Returns the difference in days between input $tstamp and $EXEC_TIME

public static daysUntil(int $tstamp) : int
Parameters
$tstamp : int

Time stamp, seconds

Return values
int

getAllowedFieldsForTable()

Get all fields of a table, which are allowed for the current user

public static getAllowedFieldsForTable(string $table[, bool $checkUserAccess = true ]) : array<string|int, string>
Parameters
$table : string

Table name

$checkUserAccess : bool = true

If set, users access to the field (non-exclude-fields) is checked.

Internal

should only be used from within TYPO3 Core

Return values
array<string|int, string>

Array, where values are fieldnames

getCommonSelectFields()

Returns fields for a table, $table, which would typically be interesting to select This includes uid, the fields defined for title, icon-field.

public static getCommonSelectFields(string $table[, string $prefix = '' ][, array<string|int, mixed> $fields = [] ]) : string

Returned as a list ready for query ($prefix can be set to eg. "pages." if you are selecting from the pages table and want the table name prefixed)

Parameters
$table : string

Table name, present in $GLOBALS['TCA']

$prefix : string = ''

Table prefix

$fields : array<string|int, mixed> = []

Preset fields (must include prefix if that is used)

Internal

should only be used from within TYPO3 Core

Tags
todo:

Consider dropping this method: It is used only twice and may select not actually needed fields. Also, the CSV string return is unfortunate. Consuming callers know better what they actually need, this method should be inlined to consumers instead.

Return values
string

List of fields.

getContextMenuAttributes()

public static getContextMenuAttributes(string $table[, int|string $uid = 0 ][, string $context = '' ][, string $trigger = 'click' ][, array<string|int, mixed> $row = [] ]) : array<string|int, mixed>
Parameters
$table : string

Table name/File path. If the icon is for a database record, enter the tablename from $GLOBALS['TCA']. If a file then enter the absolute filepath

$uid : int|string = 0

If icon is for database record this is the UID for the record from $table or identifier for sys_file record

$context : string = ''

Set tree if menu is called from tree view

$trigger : string = 'click'

Set the trigger the context menu is attached to. Possible options (click/contextmenu)

$row : array<string|int, mixed> = []

The record row if available

Return values
array<string|int, mixed>

getExistingPageTranslations()

Fetch all records of the given page ID.

public static getExistingPageTranslations(int $pageUid) : array<string|int, mixed>

Does not check permissions.

Parameters
$pageUid : int
Internal
Return values
array<string|int, mixed>

getGroupNames()

Returns an array with be_groups records (title, uid) of all groups NOT DELETED sorted by their title

public static getGroupNames([string $fields = 'title,uid' ][, string $where = '' ]) : array<string|int, mixed>
Parameters
$fields : string = 'title,uid'

Field list

$where : string = ''

WHERE clause

Internal

should only be used from within TYPO3 Core, use a direct SQL query instead to ensure proper DBAL where statements

Return values
array<string|int, mixed>

getItemLabel()

Returns the label-value for fieldname $column in table $table.

public static getItemLabel(string $table, string $column) : string|null
Parameters
$table : string

Table name present in $GLOBALS['TCA']

$column : string

Field name in $GLOBALS['TCA']['columns']

Return values
string|null

Value of $GLOBALS['TCA']['columns']['label'] or null if not set

getLabelFromItemlist()

Returns the label of the first found entry in an "items" array from $GLOBALS['TCA'] (tablename = $table/fieldname = $col) where the value is $key

public static getLabelFromItemlist(string $table, string $col, string $key[, array<string|int, mixed> $row = [] ]) : string
Parameters
$table : string

Table name, present in $GLOBALS['TCA']

$col : string

Field name, present in $GLOBALS['TCA']

$key : string

items-array value to match

$row : array<string|int, mixed> = []
Return values
string

Label for item entry

getLabelFromItemListMerged()

Return the label of a field by additionally checking TsConfig values

public static getLabelFromItemListMerged(int $pageId, string $table, string $column, string $key[, array<string|int, mixed> $row = [] ]) : string
Parameters
$pageId : int
$table : string

Table name

$column : string

Field Name

$key : string

item value

$row : array<string|int, mixed> = []
Return values
string

Label for item entry

getLabelsFromItemsList()

Splits the given key with commas and returns the list of all the localized items labels, separated by a comma.

public static getLabelsFromItemsList(string $table, string $column, string $keyList[, array<string|int, mixed> $columnTsConfig = [] ][, array<string|int, mixed> $row = [] ]) : string
Parameters
$table : string

Table name, present in TCA

$column : string

Field name

$keyList : string

Key or comma-separated list of keys.

$columnTsConfig : array<string|int, mixed> = []

page TSconfig for $column (TCEMAIN.

.)

$row : array<string|int, mixed> = []
Return values
string

Comma-separated list of localized labels

getLiveVersionIdOfRecord()

Gets the id of the live version of a record.

public static getLiveVersionIdOfRecord(string $table, int|string $uid) : int|null
Parameters
$table : string

Name of the table

$uid : int|string

Uid of the offline/draft record

Internal

should only be used from within TYPO3 Core

Return values
int|null

The id of the live version of the record (or NULL if nothing was found)

getLiveVersionOfRecord()

Returns live version of record

public static getLiveVersionOfRecord(string $table, int|string $uid[, string $fields = '*' ]) : array<string|int, mixed>|null
Parameters
$table : string

Table name

$uid : int|string

Record UID of draft, offline version

$fields : string = '*'

Field list, default is *

Return values
array<string|int, mixed>|null

If found, the record, otherwise NULL

getModuleData()

Returns an array which is most backend modules becomes MOD_SETTINGS containing values from function menus etc. determining the function of the module.

public static getModuleData(array<string|int, mixed> $MOD_MENU, array<string|int, mixed> $CHANGED_SETTINGS, string $modName[, string $type = '' ][, string $dontValidateList = '' ][, string $setDefaultList = '' ]) : array<string|int, mixed>

This is kind of session variable management framework for the backend users. If a key from MOD_MENU is set in the CHANGED_SETTINGS array (eg. a value is passed to the script from the outside), this value is put into the settings-array

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

MOD_MENU is an array that defines the options in menus.

$CHANGED_SETTINGS : array<string|int, mixed>

CHANGED_SETTINGS represents the array used when passing values to the script from the menus.

$modName : string

modName is the name of this module. Used to get the correct module data.

$type : string = ''

If type is 'ses' then the data is stored as session-lasting data. This means that it'll be wiped out the next time the user logs in.

$dontValidateList : string = ''

dontValidateList can be used to list variables that should not be checked if their value is found in the MOD_MENU array. Used for dynamically generated menus.

$setDefaultList : string = ''

List of default values from $MOD_MENU to set in the output array (only if the values from MOD_MENU are not arrays)

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

The array $settings, which holds a key for each MOD_MENU key and the values of each key will be within the range of values for each menuitem

getNoRecordTitle()

Get a localized [No title] string, wrapped in <em>|</em> if $prep is TRUE.

public static getNoRecordTitle([bool $prep = false ]) : string
Parameters
$prep : bool = false

Wrap result in |

Return values
string

Localized [No title] string

getPagesTSconfig()

Returns the page TSconfig for page with uid $pageUid.

public static getPagesTSconfig(int $pageUid) : array<string|int, mixed>

This method tends to be called by casual backend controllers multiple times with the same page uid, it has a runtime cache to short circuit this.

The DataHandler however tends to also call this for different page uids when doing bulk operations like multi row updates or imports, for instance by the cache flush logic. FormEngine can trigger this as well when editing multiple pages at once.

A single-level page uid -> PageTsConfig cache can be pretty memory hungry since the PageTsConfig object can be relatively huge. To prevent this method from being a memory hog, a two-level-cache is implemented: Many pages typically share the same page TSconfig. We get the rootline of a page, and create a hash from the two relevant TSconfig and tsconfig_includes fields, plus the attached site identifier. We then store a hash-to-object cache entry per different hash, and a page uid-to-hash pointer.

Parameters
$pageUid : int
Return values
array<string|int, mixed>

getPossibleWorkspaceVersionIdsOfLiveRecordIds()

Use this function if you have a large set of IDs to find out which ones have a counterpart within a workspace.

public static getPossibleWorkspaceVersionIdsOfLiveRecordIds(string $table, array<string|int, mixed> $liveRecordIds, int $workspaceId) : array<int, int>

Within a workspace, this is one additional query, so use it only if you have a set of > 2 to find out if you really need to call BackendUtility::workspaceOL() all the time.

If you have 1000 records, but only have two 2 records which have been modified in a workspace, only 2 items are returned.

Parameters
$table : string
$liveRecordIds : array<string|int, mixed>
$workspaceId : int
Internal

this method is not public API and might change, as you really should know what you are doing.

Return values
array<int, int>

keys contain the live record ID, values the versioned record ID

getProcessedValue()

Returns a human readable output of a value from a record For instance a database record relation would be looked up to display the title-value of that record. A checkbox with a "1" value would be "Yes", etc.

public static getProcessedValue(string $table, string $col, mixed $value[, int $fixed_lgd_chars = 0 ][, bool $defaultPassthrough = false ][, bool $noRecordLookup = false ][, int $uid = 0 ][, bool $forceResult = true ][, int $pid = 0 ][, array<string|int, mixed> $fullRow = [] ]) : string|null

$table/$col is tablename and fieldname REMEMBER to pass the output through htmlspecialchars() if you output it to the browser! (To protect it from XSS attacks and be XHTML compliant)

Parameters
$table : string

Table name, present in TCA

$col : string

Field name, present in TCA

$value : mixed

The value of that field from a selected record

$fixed_lgd_chars : int = 0

The max amount of characters the value may occupy

$defaultPassthrough : bool = false

Flag means that values for columns that has no conversion will just be pass through directly (otherwise cropped to 200 chars or returned as "N/A")

$noRecordLookup : bool = false

If set, no records will be looked up, UIDs are just shown.

$uid : int = 0

Uid of the current record

$forceResult : bool = true

If BackendUtility::getRecordTitle is used to process the value, this parameter is forwarded.

$pid : int = 0

Optional page uid is used to evaluate page TSconfig for the given field

$fullRow : array<string|int, mixed> = []

Optional full database row to provide additional context, e.g. to be used in itemsProcFunc

Tags
throws
InvalidArgumentException
Return values
string|null

getProcessedValueExtra()

Same as ->getProcessedValue() but will go easy on fields like "tstamp" and "pid" which are not configured in TCA - they will be formatted by this function instead.

public static getProcessedValueExtra(string $table, string $fN, string $fV[, int $fixed_lgd_chars = 0 ][, int $uid = 0 ][, bool $forceResult = true ][, int $pid = 0 ][, array<string|int, mixed> $fullRow = [] ]) : string
Parameters
$table : string

Table name, present in TCA

$fN : string

Field name

$fV : string

Field value

$fixed_lgd_chars : int = 0

The max amount of characters the value may occupy

$uid : int = 0

Uid of the current record

$forceResult : bool = true

If BackendUtility::getRecordTitle is used to process the value, this parameter is forwarded.

$pid : int = 0

Optional page uid is used to evaluate page TSconfig for the given field

$fullRow : array<string|int, mixed> = []

Optional full database row to provide additional context, e.g. to be used in itemsProcFunc

Tags
see
getProcessedValue()
Return values
string

getRecord()

Gets record with uid = $uid from $table You can set $field to a list of fields (default is '*') Additional WHERE clauses can be added by $where (fx. ' AND some_field = 1') Will automatically check if records has been deleted and if so, not return anything.

public static getRecord(string $table, int|string $uid[, string $fields = '*' ][, string $where = '' ][, bool $useDeleteClause = true ]) : array<string|int, mixed>|null

$table must be found in $GLOBALS['TCA']

Parameters
$table : string

Table name present in $GLOBALS['TCA']

$uid : int|string

UID of record

$fields : string = '*'

List of fields to select

$where : string = ''

Additional WHERE clause, eg. ' AND some_field = 0'

$useDeleteClause : bool = true

Use the deleteClause to check if a record is deleted (default TRUE)

Return values
array<string|int, mixed>|null

Returns the row if found, otherwise NULL

getRecordIconAltText()

Returns title-attribute information for ANY record (from a table defined in TCA of course) The included information depends on features of the table, but if hidden, starttime, endtime and fe_group fields are configured for, information about the record status in regard to these features are is included.

public static getRecordIconAltText(array<string|int, mixed> $row[, string $table = 'pages' ][, bool $escapeResult = true ]) : string

"pages" table can be used as well and will return the result of ->titleAttribForPages() for that page.

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

Table row; $row is a row from the table, $table

$table : string = 'pages'

Table name

$escapeResult : bool = true

If $escapeResult is set, then the return value is escaped with htmlspecialchars()

Return values
string

getRecordLocalization()

Fetches the localization for a given record.

public static getRecordLocalization(string $table, int $uid, int $language[, string $andWhereClause = '' ]) : mixed
Parameters
$table : string

Table name present in $GLOBALS['TCA']

$uid : int

The uid of the record

$language : int

The id of the site language

$andWhereClause : string = ''

Optional additional WHERE clause (default: '')

Return values
mixed

Multidimensional array with selected records, empty array if none exists and FALSE if table is not localizable

getRecordPath()

Returns the path (visually) of a page $uid, fx. "/First page/Second page/Another subpage" Each part of the path will be limited to $titleLimit characters Deleted pages are filtered out.

public static getRecordPath(int $uid, string $clause, int $titleLimit[, int $fullTitleLimit = 0 ]) : mixed
Parameters
$uid : int

Page uid for which to create record path

$clause : string

Clause is additional where clauses, eg.

$titleLimit : int

Title limit

$fullTitleLimit : int = 0

Title limit of Full title (typ. set to 1000 or so)

Return values
mixed

Path of record (string) OR array with short/long title if $fullTitleLimit is set.

getRecordTitle()

Returns the "title"-value in record, $row, from table, $table The field(s) from which the value is taken is determined by the "ctrl"-entries 'label', 'label_alt' and 'label_alt_force'

public static getRecordTitle(string $table, array<string|int, mixed> $row[, bool $prep = false ][, bool $forceResult = true ]) : string
Parameters
$table : string

Table name, present in TCA

$row : array<string|int, mixed>

Row from table

$prep : bool = false

If set, result is prepared for output: The output is cropped to a limited length (depending on BE_USER->uc['titleLen']) and if no value is found for the title, '[No title]' is returned (localized). Further, the output is htmlspecialchars()'ed

$forceResult : bool = true

If set, the function always returns an output. If no value is found for the title, '[No title]' is returned (localized).

Return values
string

getRecordTitlePrep()

Crops a title string to a limited length and if it really was cropped, wrap it in a <span title="...">|</span>, which offers a tooltip with the original title when moving mouse over it.

public static getRecordTitlePrep(string $title[, int $titleLength = 0 ]) : string
Parameters
$title : string

The title string to be cropped

$titleLength : int = 0

Crop title after this length - if not set, BE_USER->uc['titleLen'] is used

Return values
string

The processed title string, wrapped in | if cropped

getRecordWSOL()

Like getRecord(), but overlays workspace version if any.

public static getRecordWSOL(string $table, int $uid[, string $fields = '*' ][, string $where = '' ][, bool $useDeleteClause = true ][, bool $unsetMovePointers = false ]) : array<string|int, mixed>|null
Parameters
$table : string

Table name present in $GLOBALS['TCA']

$uid : int

UID of record

$fields : string = '*'

List of fields to select

$where : string = ''

Additional WHERE clause, eg. ' AND some_field = 0'

$useDeleteClause : bool = true

Use the deleteClause to check if a record is deleted (default TRUE)

$unsetMovePointers : bool = false

If TRUE the function does not return a "pointer" row for moved records in a workspace

Return values
array<string|int, mixed>|null

Returns the row if found, else NULL

getTCAtypeValue()

Returns the "type" value of $rec from $table which can be used to look up the correct "types" rendering section in $GLOBALS['TCA'] If no "type" field is configured in the "ctrl"-section of the $GLOBALS['TCA'] for the table, zero is used.

public static getTCAtypeValue(string $table, array<string|int, mixed> $row) : string

If zero is not an index in the "types" section of $GLOBALS['TCA'] for the table, then the $fieldValue returned will default to 1 (no matter if that is an index or not)

Note: This method is very similar to the type determination of FormDataProvider/DatabaseRecordTypeValue, however, it has two differences:

  1. The method in TCEForms also takes care of localization (which is difficult to do here as the whole infrastructure for language overlays is only in TCEforms).
  2. The $row array looks different in TCEForms, as in there it's not the raw record but the prepared data from other providers is handled, which changes e.g. how "select" and "group" field values are stored, which makes different processing of the "foreign pointer field" type field variant necessary.
Parameters
$table : string

Table name present in TCA

$row : array<string|int, mixed>

Record from $table

Tags
throws
RuntimeException
Return values
string

Field value

getTCEFORM_TSconfig()

Returns TSConfig for the TCEFORM object in page TSconfig.

public static getTCEFORM_TSconfig(string $table, array<string|int, mixed> $row) : array<string|int, mixed>

Used in TCEFORMs

Parameters
$table : string

Table name present in TCA

$row : array<string|int, mixed>

Row from table

Return values
array<string|int, mixed>

getTSconfig_pidValue()

Find the real PID of the record (with $uid from $table).

public static getTSconfig_pidValue(string $table, int $uid, int|string $pid) : int|null

This MAY be impossible if the pid is set as a reference to the former record or a page (if two records are created at one time).

Parameters
$table : string

Table name

$uid : int

Record uid

$pid : int|string

Record pid, could be negative then pointing to a record from same table whose pid to find and return

Internal
Tags
see
DataHandler::copyRecord()
see
BackendUtility::getTSCpid()
Return values
int|null

getTSCpid()

Returns the REAL pid of the record, if possible. If both $uid and $pid is strings, then pid=-1 is returned as an error indication.

public static getTSCpid(string $table, int $uid, int|string $pid) : array<string|int, mixed>
Parameters
$table : string

Table name

$uid : int

Record uid

$pid : int|string

Record pid

Internal
Tags
see
DataHandler::setHistory()
see
DataHandler::process_datamap()
Return values
array<string|int, mixed>

Array of two integers; first is the REAL PID of a record and if its a new record negative values are resolved to the true PID, second value is the PID value for TSconfig (uid if table is pages, otherwise the pid)

getTSCpidCached()

Return the real pid of a record and caches the result.

public static getTSCpidCached(string $table, string $uid, string $pid) : array<string|int, mixed>

The non-cached method needs database queries to do the job, so this method can be used if code sometimes calls the same record multiple times to save some queries. This should not be done if the calling code may change the same record meanwhile.

Parameters
$table : string

Tablename

$uid : string

UID value

$pid : string

PID value

Return values
array<string|int, mixed>

Array of two integers; first is the real PID of a record, second is the PID value for TSconfig.

getUpdateSignalDetails()

Gets instructions for update signals (e.g. page tree shall be refreshed, since some page title has been modified during the current HTTP request).

public static getUpdateSignalDetails() : array{html: list}
Tags
see
BackendUtility::setUpdateSignal()
Return values
array{html: list}

getUserNames()

Returns an array with be_users records of all user NOT DELETED sorted by their username Keys in the array is the be_users uid

public static getUserNames([string $fields = 'username,usergroup,uid' ][, string $where = '' ]) : array<string|int, mixed>
Parameters
$fields : string = 'username,usergroup,uid'

Optional $fields list (default: username,usergroup,uid) can be used to set the selected fields

$where : string = ''

Optional $where clause (fx. "AND username='pete'") can be used to limit query

Internal

should only be used from within TYPO3 Core, use a direct SQL query instead to ensure proper DBAL where statements

Return values
array<string|int, mixed>

getWorkspaceVersionOfRecord()

Select the workspace version of a record, if exists

public static getWorkspaceVersionOfRecord(int $workspace, string $table, int $uid[, string $fields = '*' ]) : array<string|int, mixed>|bool
Parameters
$workspace : int

Workspace ID

$table : string

Table name to select from

$uid : int

Record uid for which to find workspace version.

$fields : string = '*'

Field list to select

Return values
array<string|int, mixed>|bool

If found, return record, otherwise false

isRecordLocked()

Returns information about whether the record from table, $table, with uid, $uid is currently locked (edited by another user - which should issue a warning).

public static isRecordLocked(string $table, int $uid) : array<string|int, mixed>|bool

Notice: Locking is not strictly carried out since locking is abandoned when other backend scripts are activated - which means that a user CAN have a record "open" without having it locked. So this just serves as a warning that counts well in 90% of the cases, which should be sufficient.

Parameters
$table : string

Table name

$uid : int

Record uid

Internal
Return values
array<string|int, mixed>|bool

isRootLevelRestrictionIgnored()

Whether to ignore restrictions on root-level records.

public static isRootLevelRestrictionIgnored(string $table) : bool

The regular behaviour is that records on the root-level (page-id 0) only can be accessed by admin users.

Parameters
$table : string

Name of the table

Return values
bool

isTableLocalizable()

Determines whether a table is localizable and has the languageField and transOrigPointerField set in $GLOBALS['TCA'].

public static isTableLocalizable(string $table) : bool
Parameters
$table : string

The table to check

Return values
bool

Whether a table is localizable

isTableWorkspaceEnabled()

Determines whether a table is enabled for workspaces.

public static isTableWorkspaceEnabled(string $table) : bool
Parameters
$table : string

Name of the table to be checked

Return values
bool

isWebMountRestrictionIgnored()

Whether to ignore restrictions on a web-mount of a table.

public static isWebMountRestrictionIgnored(string $table) : bool

The regular behaviour is that records to be accessed need to be in a valid user's web-mount.

Parameters
$table : string

Name of the table

Return values
bool

lockRecords()

Unlock or Lock a record from $table with $uid If $table and $uid is not set, then all locking for the current BE_USER is removed!

public static lockRecords([string $table = '' ][, int $uid = 0 ][, int $pid = 0 ]) : mixed
Parameters
$table : string = ''

Table name

$uid : int = 0

Record uid

$pid : int = 0

Record pid

Internal

openPageTree()

Opens the page tree to the specified page id

public static openPageTree(int $pid, bool $clearExpansion) : mixed
Parameters
$pid : int

Page id.

$clearExpansion : bool

If set, then other open branches are closed.

Internal

should only be used from within TYPO3 Core

purgeComputedPropertiesFromRecord()

Purges computed properties starting with underscore character ('_').

public static purgeComputedPropertiesFromRecord(array<string, mixed> $record) : array<string, mixed>
Parameters
$record : array<string, mixed>
Internal

should only be used from within TYPO3 Core

Return values
array<string, mixed>

purgeComputedPropertyNames()

Purges computed property names starting with underscore character ('_').

public static purgeComputedPropertyNames(array<string|int, mixed> $propertyNames) : array<string|int, mixed>
Parameters
$propertyNames : array<string|int, mixed>
Internal

should only be used from within TYPO3 Core

Return values
array<string|int, mixed>

readPageAccess()

Returns a page record (of page with $id) with an extra field "_thePath" set to the record path if the WHERE clause $perms_clause selects the record. This works as an access check that returns a page record if access was granted, otherwise false.

public static readPageAccess(int $id, string $perms_clause) : array<string|int, mixed>|false

If $id is zero a pseudo root-page with "_thePath" set is returned IF the current BE_USER is admin. In any case ->isInWebMount must return TRUE for the user (regardless of $perms_clause)

Parameters
$id : int

Page uid for which to check read-access

$perms_clause : string

This is typically a value generated with static::getBackendUserAuthentication()->getPagePermsClause(1);

Return values
array<string|int, mixed>|false

Returns page record if OK, otherwise FALSE.

referenceCount()

Counting references to a record/file

public static referenceCount(string $table, int $ref[, string $msg = '' ][, string|int|null $count = null ]) : string|int
Parameters
$table : string

Table name

$ref : int

Record uid

$msg : string = ''

Message with %s, e.g. "There were %s records pointing to this file!"

$count : string|int|null = null

Reference count

Tags
todo:

The method should vanish altogether: The signature with $msg and $count and string|int return value is odd, and the method contains hacks for sys_file.

Return values
string|int

Output string (or int count value if no msg string specified)

resolveFileReferences()

Resolves file references for a given record.

public static resolveFileReferences(string $tableName, string $fieldName, array<string|int, mixed> $element[, int|null $workspaceId = null ]) : array<string|int, FileReference>|null
Parameters
$tableName : string

Name of the table of the record

$fieldName : string

Name of the field of the record

$element : array<string|int, mixed>

Record data

$workspaceId : int|null = null

Workspace to fetch data for

Return values
array<string|int, FileReference>|null

selectVersionsOfRecord()

Select all versions of a record, ordered by latest created version (uid DESC)

public static selectVersionsOfRecord(string $table, int $uid[, string $fields = '*' ][, int|null $workspace = 0 ][, bool $includeDeletedRecords = false ][, array<string|int, mixed> $row = null ]) : array<string|int, mixed>|null
Parameters
$table : string

Table name to select from

$uid : int

Record uid for which to find versions.

$fields : string = '*'

Field list to select

$workspace : int|null = 0

Search in workspace ID and Live WS, if 0 search only in LiveWS, if NULL search in all WS.

$includeDeletedRecords : bool = false

If set, deleted-flagged versions are included! (Only for clean-up script!)

$row : array<string|int, mixed> = null

The current record

Internal

should only be used from within TYPO3 Core

Return values
array<string|int, mixed>|null

Array of versions of table/uid

setUpdateSignal()

Call to update the page tree frame (or something else..?) after use 'updatePageTree' as a first parameter will set the page tree to be updated.

public static setUpdateSignal([string $set = '' ][, mixed $params = '' ]) : mixed
Parameters
$set : string = ''

Key to set the update signal. When setting, this value contains strings telling WHAT to set. At this point it seems that the value "updatePageTree" is the only one it makes sense to set. If empty, all update signals will be removed.

$params : mixed = ''

Additional information for the update signal, used to only refresh a branch of the tree

Tags
see
BackendUtility::getUpdateSignalDetails()

splitTable_Uid()

Makes a backwards explode on the $str and returns an array with ($table, $uid).

public static splitTable_Uid(string $str) : array<string|int, mixed>

Example: tt_content_45 => ['tt_content', 45]

Parameters
$str : string

[tablename]_[uid] string to explode

Internal

should only be used from within TYPO3 Core

Return values
array<string|int, mixed>

time()

Returns $value (in seconds) formatted as hh:mm:ss For instance $value = 3600 + 60*2 + 3 should return "01:02:03"

public static time(int $value[, bool $withSeconds = true ]) : string
Parameters
$value : int

Time stamp, seconds

$withSeconds : bool = true

Output hh:mm:ss. If FALSE: hh:mm

Return values
string

Formatted time

titleAttribForPages()

Returns title-attribute information for a page-record informing about id, doktype, hidden, starttime, endtime, fe_group etc.

public static titleAttribForPages(array<string|int, mixed> $row[, string $perms_clause = '' ][, bool $includeAttrib = true ][, bool $preferNavTitle = false ]) : string
Parameters
$row : array<string|int, mixed>

Input must be a page row ($row) with the proper fields set (be sure - send the full range of fields for the table)

$perms_clause : string = ''

This is used to get the record path of the shortcut page, if any (and doktype==4)

$includeAttrib : bool = true

If $includeAttrib is set, then the 'title=""' attribute is wrapped about the return value, which is in any case htmlspecialchar()'ed already

$preferNavTitle : bool = false

Prefers the 'nav_title' if available over the 'title' (nessesary for Tree with options.pageTree.showNavTitle = 1)

Return values
string

translationCount()

Counting translations of records

public static translationCount(string $table, string $ref[, string $msg = '' ]) : string
Parameters
$table : string

Table name

$ref : string

Reference: the record's uid

$msg : string = ''

Message with %s, eg. "This record has %s translation(s) which will be deleted, too!

Return values
string

Output string (or int count value if no msg string specified)

workspaceOL()

Workspace Preview Overlay.

public static workspaceOL(string $table, array<string|int, mixed>|null &$row[, int $wsid = -99 ][, bool $unsetMovePointers = false ]) : mixed

Generally ALWAYS used when records are selected based on uid or pid. Principle; Record online! => Find offline? The function MAY set $row to FALSE. This happens if a moved record is given and $unsetMovePointers is set to true. In other words, you should check if the input record is still an array afterwards when using this function.

If the versioned record is a moved record the "pid" value will then contain the newly moved location and "ORIG_pid" will contain the live pid.

Parameters
$table : string

Table name

$row : array<string|int, mixed>|null

Record by reference. At least "uid", "pid", "t3ver_oid" and "t3ver_state" must be set. Keys not prefixed with '_' are used as field names in SQL.

$wsid : int = -99

Workspace ID, if not specified will use static::getBackendUserAuthentication()->workspace

$unsetMovePointers : bool = false

If TRUE the function does not return a "pointer" row for moved records in a workspace

wrapClickMenuOnIcon()

Makes click menu link (context sensitive menu)

public static wrapClickMenuOnIcon(string $content, string $table[, int|string $uid = 0 ][, string $context = '' ][, array<string|int, mixed> $row = [] ]) : string

Returns $str wrapped in a link which will activate the context sensitive menu for the record ($table/$uid) or file ($table = file) The link will load the top frame with the parameter "&item" which is the table, uid and context arguments imploded by "|": rawurlencode($table.'|'.$uid.'|'.$context)

Parameters
$content : string

String to be wrapped in link, typ. image tag.

$table : string

Table name/File path. If the icon is for a database record, enter the tablename from $GLOBALS['TCA']. If a file then enter the absolute filepath

$uid : int|string = 0

If icon is for database record this is the UID for the record from $table or identifier for sys_file record

$context : string = ''

Set tree if menu is called from tree view

$row : array<string|int, mixed> = []

The record row if available

Return values
string

The link wrapped input string.

wsMapId()

Performs mapping of new uids to new versions UID in case of import inside a workspace.

public static wsMapId(string $table, int $uid) : int
Parameters
$table : string

Table name

$uid : int

Record uid (of live record placeholder)

Internal

should only be used from within TYPO3 Core

Return values
int

Uid of offline version if any, otherwise live uid.

getConnectionForTable()

protected static getConnectionForTable(string $table) : Connection
Parameters
$table : string
Return values
Connection

getLogger()

protected static getLogger() : LoggerInterface
Return values
LoggerInterface

getPageForRootline()

Gets the cached page record for the rootline

protected static getPageForRootline(int $uid, string $clause, bool $workspaceOL[, array<string|int, string> $additionalFields = [] ]) : array<string|int, mixed>
Parameters
$uid : int

Page id for which to create the root line.

$clause : string

Clause can be used to select other criteria. It would typically be where-clauses that stops the process if we meet a page, the user has no reading access to.

$workspaceOL : bool

If TRUE, version overlay is applied. This must be requested specifically because it is usually only wanted when the rootline is used for visual output while for permission checking you want the raw thing!

$additionalFields : array<string|int, string> = []

AdditionalFields to fetch from the root line

Tags
see
BEgetRootLine
Return values
array<string|int, mixed>

Cached page record for the rootline

getRecordsSortedByTitle()

Returns an array of all non-deleted records of a table sorted by a given title field.

protected static getRecordsSortedByTitle(array<string|int, mixed> $fields, string $table, string $titleField[, string $where = '' ]) : array<string|int, mixed>

The value of the title field will be replaced by the return value of self::getRecordTitle() before the sorting is performed.

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

Fields to select

$table : string

Table name

$titleField : string

Field that will contain the record title

$where : string = ''

Additional where clause

Return values
array<string|int, mixed>

Array of sorted records

resolveRelationLabels()

Helper method to fetch all labels for all relations of processed Values.

protected static resolveRelationLabels(array<string|int, mixed> $theColConf, string $table, string|int|null $recordId, string|int $value, bool $noRecordLookup) : array<string|int, mixed>
Parameters
$theColConf : array<string|int, mixed>
$table : string
$recordId : string|int|null
$value : string|int
$noRecordLookup : bool
Return values
array<string|int, mixed>

        
On this page

Search results