TcaSchemaFactory

class \TYPO3\CMS\Core\Schema\TcaSchemaFactory

Create Schema objects from information stored in TCA.

A TcaSchema contains:

  • a list of all fields as defined in [columns]
  • a list of "capabilities" (parts defined in the [ctrl] section)
  • a list of sub-schemata (if there is a [ctrl][type] definition, then sub-schemata are instances of TcaSchema itself again)
  • a list of possible relations of other schemata pointing to this schema ("Passive Relations")

As the relations need to be fully resolved first (done in RelationMapBuilder), the TcaSchemaFactory does two-step processing: 1a. Traverse TCA (and, if type=flex parts are registered), and find relations of all TCA parts pointing to each other 1b. Store this in a RelationMap object as a multi-level array.

  1. Loop through all TCA tables one by one 2a. Build field objects for the TCA table. 2b. Detect "sub schemata" (if [ctrl][type] is set), build the field objects only relevant for the sub-schema 2c. Build the sub-schema 2d. Build the main schema

This is done that way to ensure that all objects can not be modified anymore, and we have a complete representation of the data structures available.

Attributes

#[Autoconfigure]
$public: true
$shared: true

Table of Contents

Properties

$cache  : PhpFrontend
$cacheIdentifier  : string
$fieldTypeFactory  : FieldTypeFactory
$relationMapBuilder  : RelationMapBuilder
$schemata  : array

Methods

__construct()  : mixed
all()  : SchemaCollection<string, TcaSchema>
Returns all main schemata
get()  : TcaSchema
Get a schema from the loaded TCA. Ensure to check for a schema with ->has() before calling ->get().
has()  : bool
Checks if a schema exists, does not build the schema if not needed, thus it's very slim and only creates a schema if a sub-schema is requested.
load()  : void
Load TCA and populate all schema - throws away existing schema if $force is set.
rebuild()  : void
Only used for functional tests, which override TCA on the fly for specific test cases.
warmupCaches()  : void
build()  : TcaSchema
Builds a schema from a TCA table, if a sub-schema is requested, it will build the main schema and all sub-schematas first.
findRelevantFieldsForSubSchema()  : array
getFinalFieldConfiguration()  : array
Handles the label and possible columnsOverrides

Properties

$cacheIdentifier read-only

protected string $cacheIdentifier

Attributes

#[Autowire]
$expression: 'service("package-dependent-cache-identifier").withPrefix("TcaSchema").toString()'

Methods

get()

Get a schema from the loaded TCA. Ensure to check for a schema with ->has() before calling ->get().

public get(string $schemaName) : TcaSchema

Parameters

$schemaName : string

Return values

TcaSchema

has()

Checks if a schema exists, does not build the schema if not needed, thus it's very slim and only creates a schema if a sub-schema is requested.

public has(string $schemaName) : bool

Parameters

$schemaName : string

Return values

bool

load()

Load TCA and populate all schema - throws away existing schema if $force is set.

public load(array $tca[, bool $force = false ]) : void

Parameters

$tca : array
$force : bool = false

rebuild()

Only used for functional tests, which override TCA on the fly for specific test cases.

public rebuild(array $fullTca) : void

Modifying TCA other than in Configuration/TCA/Overrides must be avoided in production code.

Parameters

$fullTca : array

build()

Builds a schema from a TCA table, if a sub-schema is requested, it will build the main schema and all sub-schematas first.

protected build(string $schemaName, array $fullTca, RelationMap $relationMap) : TcaSchema

First builds all fields, then the schema and attach the fields, so all parts can never be modified (except for adding sub-schema - this might be removed at some point hopefully).

Then, resolves the sub-schema and the relevant fields for there with columnsOverrides taken into account.

As it is crucial to understand, parts such as FlexForms (incl. Sheet, SectionContainers and their Fields) NEED to be resolved first, because they need to be attached.

Parameters

$schemaName : string
$fullTca : array
$relationMap : RelationMap

Return values

TcaSchema

findRelevantFieldsForSubSchema()

protected findRelevantFieldsForSubSchema(array $tcaForTable, string $subSchemaName) : array

Parameters

$tcaForTable : array
$subSchemaName : string

Return values

array

getFinalFieldConfiguration()

Handles the label and possible columnsOverrides

protected getFinalFieldConfiguration(string $fieldName, array $schemaConfiguration, array $subSchemaConfiguration, string|null $fieldLabel) : array

Parameters

$fieldName : string
$schemaConfiguration : array
$subSchemaConfiguration : array
$fieldLabel : string|null

Return values

array
On this page