TCA Utility¶
Utility Class for working faster with the TCA.
-
class
Jar\Utilities\Utilities\
TcaUtility
¶
-
Jar\Utilities\Utilities\TcaUtility::
getColumnsByType
($table, $type)¶ Returns active columns by TCA type.
Parameters: - $table (string) – The table name.
- $type (string) – The type name.
Returns: List of column names.
Example:
var_dump(TcaUtility::getColumnsByType('tt_content', 'html')); // ['CType', 'colPos', 'header', 'bodytext', 'layout', 'frame_class', ... ] var_dump(TcaUtility::getColumnsByType('tt_content', 'image')); // ['CType', 'colPos', 'header', ..., 'image', 'imagewidth', 'imageheight', ...]
-
Jar\Utilities\Utilities\TcaUtility::
getColumnsByRow
($table, $row)¶ Returns active columns based on a table record.
Parameters: - $table (string) – The table name.
- $row (array) – The table record.
Returns: List of column names.
Example:
// Shorthand for: TcaUtility::getColumnsByType( TcaUtility::getTypeFromRow( $row )); // Example output, see above under "getColumnsByType".
-
Jar\Utilities\Utilities\TcaUtility::
getColumnsByTable
($table)¶ Returns all default (first type) columns from a table.
Parameters: - $table (string) – The table name.
Returns: List of column names.
-
Jar\Utilities\Utilities\TcaUtility::
getTypeFromRow
($table, $row)¶ Returns actice TCA type based on a table record.
Parameters: - $table (string) – The table name.
- $row (array) – The table record.
Returns: Name of the type will fallback to default type when no individual type is found.
-
Jar\Utilities\Utilities\TcaUtility::
getVisibleColumnsByRow
($table, $row)¶ Just return the columns which are visible for the current Backend User, respects current active display conditions of fields.
Parameters: - $table (string) – The table name.
- $row (array) – The table record.
Returns: List of column names.
-
Jar\Utilities\Utilities\TcaUtility::
getTypeFieldOfTable
($table)¶ Returns the column name which contains the “type” value from a table.
Parameters: - $table (string) – The table name.
Returns: The name of the “type” column.
-
Jar\Utilities\Utilities\TcaUtility::
getLabelFieldOfTable
($table)¶ Returns the column name which contains the “label” value from a table.
Parameters: - $table (string) – The table name.
Returns: The name of the “label” column.
-
Jar\Utilities\Utilities\TcaUtility::
getLabelFromRow
($row, $table)¶ Returns the label from a table record.
Parameters: - $row (array) – The table record.
- $table (string) – The table name.
Returns: The label or “null” when empty.
Example:
TcaUtility::getLabelFromRow([ 'uid' => 3, 'doktype => 254', 'title' => 'Elemente', /* ... */ ], 'pages'); // returns "Elemente"
-
Jar\Utilities\Utilities\TcaUtility::
mapStringListToColumns
($list, $table = null)¶ Converts a comma-separated list of TCA Columns (a,b,c) to [a,b,c]. Also columns of containing pallets will be resolved (if parameter table is available).
Parameters: - $list (string) – Comma-separated list of TCA Columns.
- $table (string) – The table name.
Returns: List of column names.
-
Jar\Utilities\Utilities\TcaUtility::
getFieldDefinition
($table, $column, $type = null)¶ Returns the current TCA field definition from a table column. Also resolves column overrides when parameter “type” is set.
Parameters: - $table (string) – The table name.
- $column (string) – The column name.
- $type (null|string) – The type to respect column overrides.
Returns: The field definition or “null” when no field definition is found.
-
Jar\Utilities\Utilities\TcaUtility::
getFieldConfig
($table, $column, $type = null)¶ Returns the TCA field configuration from a table column.
Parameters: - $table (string) – The table name.
- $column (string) – The column name.
- $type (null|string) – The type to respect column overrides.
Returns: The field configuration or “null” when no field configuration is found.
-
Jar\Utilities\Utilities\TcaUtility::
remapItemArrayToKeybasedList
($items)¶ Converts a TCA item array to a key-based list.
Parameters: - $items (array) – TCA item array.
Returns: Key-based list.
Example:
TcaUtility::remapItemArrayToKeybasedList([['LLL:.../locallang.xlf:creation', 'uid'], ['LLL:.../locallang.xlf:backendsorting', 'sorting']]); // returns: [ 'uid' => [ 'label' => 'LLL:.../locallang.xlf:creation', 'icon' => null ], 'sorting' => [ 'label' => 'LLL:.../locallang.xlf:backendsorting', 'icon' => null ] ]
-
Jar\Utilities\Utilities\TcaUtility::
getLabelOfSelectedItem
($value, $column, $table, $type = null, $localize = true)¶ Load the backend label from a selected item.
Parameters: - $value (string) – The selected item. F.e [‘LLL:…/locallang.xlf:backendsorting’, ‘sorting’]
- $column (string) – Column name which contains the selected item.
- $table (string) – The table name.
- $type (null|string) – The type to respect column overrides.
- $localize (boolean) – If false return the raw value, otherwise return the translated value.
Returns: The label.
-
Jar\Utilities\Utilities\TcaUtility::
getL10nConfig
($table)¶ Returns the TCA language fields from a table or null, if not set.
Parameters: - $table (string) – The table name.
Returns: TCA language fields from a table or null, if not set
-
Jar\Utilities\Utilities\TcaUtility::
getTca
()¶ Returns the current TCA.
Returns: The TCA.