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

Public Member Functions

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

Protected Member Functions

 enrichSingleTableFields ($tables)
 
 enrichMmTables ($tables)
 
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 37 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[] Modified tables

Definition at line 48 of file DefaultTcaSchema.php.

References TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichMmTables(), and TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichSingleTableFields().

◆ enrichMmTables()

TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema::enrichMmTables (   $tables)
protected

Find table fields that configure a "true" MM relation and define the according mm table schema for them. True MM tables are intermediate tables that have NO TCA itself. Those are indicated by type=select and type=group and type=inline fields with MM property.

Definition at line 484 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().

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

◆ enrichSingleTableFields()

◆ 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. This has is done for cosmetically reasons to improve readability of db schema when opening tables in a database browser.

Parameters
string$tableName
Returns
‪string[]

Definition at line 637 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 790 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichMmTables(), and TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichSingleTableFields().

◆ 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 735 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichMmTables(), and TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichSingleTableFields().

◆ 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 760 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichMmTables(), and TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichSingleTableFields().

◆ 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 716 of file DefaultTcaSchema.php.

Referenced by TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichMmTables(), and TYPO3\CMS\Core\Database\Schema\DefaultTcaSchema\enrichSingleTableFields().

◆ quote()

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