‪TYPO3CMS  9.5
TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema Class Reference

Public Member Functions

Table[] enrich (array $tables)
 
string[] getPrioritizedFieldNames (string $tableName)
 

Protected Member Functions

bool isTableDefined (array $tables, string $tableName)
 
bool isColumnDefinedForTable (array $tables, string $tableName, string $fieldName)
 
bool isIndexDefinedForTable (array $tables, string $tableName, string $indexName)
 
int getTableFirstPosition (array $tables, string $tableName)
 
string quote (string $identifier)
 

Detailed Description

This class is called by the SchemaMigrator after all extension's ext_tables.sql files have been parsed and processed to the doctrine Table/Column/Index objects.

Method enrich() goes through all $GLOBALS['TCA'] tables and adds fields like 'uid', 'sorting', 'deleted' and friends if the feature is enabled in TCA and the field has not been defined in ext_tables.sql files.

This allows extension developers to leave out the TYPO3 DB management fields and reduce ext_tables.sql of extensions down to the business fields.

Definition at line 34 of file DefaultTcaSchema.php.

Member Function Documentation

◆ enrich()

Table [] TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::enrich ( array  $tables)

Add fields to $tables array that has been created from ext_tables.sql files. This goes through all tables defined in TCA, looks for 'ctrl' features like "soft delete" ['ctrl']['delete'] and adds the field if it has not been defined in ext_tables.sql, yet.

Parameters
Table[]$tables
Returns
‪Table[]

Definition at line 46 of file DefaultTcaSchema.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\getTableFirstPosition(), TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\isColumnDefinedForTable(), TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\isIndexDefinedForTable(), TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\isTableDefined(), and TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\quote().

◆ getPrioritizedFieldNames()

string [] TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::getPrioritizedFieldNames ( string  $tableName)

If the enrich() method adds fields, they should be added in the beginning of a table.

Parameters
string$tableName
Returns
‪string[]

Definition at line 521 of file DefaultTcaSchema.php.

References $GLOBALS.

◆ getTableFirstPosition()

int TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::getTableFirstPosition ( array  $tables,
string  $tableName 
)
protected

The incoming $tables array can contain Table objects for the same table multiple times. This can happen if an extension has the main CREATE TABLE statement in its ext_tables.sql and another extension adds or changes further fields in an own CREATE TABLE statement.

Todo:

It would be better if the incoming $tables structure would be cleaned

to contain a table only once before this class is entered.

Parameters
Table[]$tables
string$tableName
Returns
‪int
Exceptions

Definition at line 679 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrich().

◆ isColumnDefinedForTable()

bool TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::isColumnDefinedForTable ( array  $tables,
string  $tableName,
string  $fieldName 
)
protected

True if a column with a given name is defined within the incoming array of Table's.

Parameters
Table[]$tables
string$tableName
string$fieldName
Returns
‪bool

Definition at line 624 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrich().

◆ isIndexDefinedForTable()

bool TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::isIndexDefinedForTable ( array  $tables,
string  $tableName,
string  $indexName 
)
protected

True if an index with a given name is defined within the incoming array of Table's.

Parameters
Table[]$tables
string$tableName
string$indexName
Returns
‪bool

Definition at line 649 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrich().

◆ isTableDefined()

bool TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::isTableDefined ( array  $tables,
string  $tableName 
)
protected

True if table with given table name is defined within incoming $tables array

Parameters
Table[]$tables
string$tableName
Returns
‪bool

Definition at line 605 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrich().

◆ quote()

string TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::quote ( string  $identifier)
protected
Parameters
string$identifier
Returns
‪string

Definition at line 693 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrich().