Storing modifications
There are various ways to store modifications to
$GLOBALS. They
depend on what you are trying to achieve and the version of TYPO3 CMS you are
targeting. The TCA can only be modified from inside an extension.
Changed in version 14.0
There are two changes to
\TYPO3\.
The second argument
$type and the third argument
$extension
have been dropped.
Storing in extensions
The advantage of putting modifications inside extensions is that the modifications are packaged in a self-contained entity that can be easily deployed.
The drawback is that extension loading order must be finely controlled. If you are modifying Core TCA, you usually don't have to worry about loading order. Custom extensions are always loaded after the Core TCA, so modifications from custom extensions should always take effect.
If your extension modifies another extension, make sure your extension is loaded after the extension you are modifying. You can do this by registering the other extension as a dependency (or suggestion) of yours. See the description of constraints in Core APIs.
Loading order also matters if you have multiple extensions overriding the same field or contradicting each other.
Files in Configuration/ are loaded inside a dedicated scope. This means
that variables defined in those files cannot leak into other files.
For more information about extension structure, please refer to the extension architecture chapter.
Storing in the Overrides/ folder
Modifications to
$GLOBALS
must be stored in Configuration/. For clarity, files should
be named <tablename>..
For example, if you want to modify the TCA of
tx_,
create file Configuration/TCA/Overrides/tx_foo_domain_model_bar.php.
The advantage of this method is that changes will be incorporated into
$GLOBALS before it is cached (which is very efficient).
Note
All files in Configuration/ will be loaded, so you can
divide up long files such as for table "tt_content" rather than
having one long file. Otherwise, if you have custom
content elements this file can reach 1000+ lines very quickly, affecting
maintainability.
Also, names don't matter in this folder, at least not to TYPO3. They only influence
loading order. Proper naming is only relevant for the table definitions one
folder up in Configuration/
Attention
You cannot extend the TCA of an extension if the modifications
are in its ext_tables.php file (usually a "ctrl" section
referencing a "dynamicConfigFile"). Please ask the extension author to switch
to the Configuration/ setup.
Attention
Only TCA-related modifications should go in Configuration/
files. Some API calls may be okay if all they do is manipulate
$GLOBALS. For example, a plugin can be registered with
\TYPO3\ in
Configuration/TCA/Overrides/tt_content.php because the API call only
modifies
$GLOBALS for table
tt_.
Changing the TCA "on the fly"
It is possible to manipulate
$GLOBALS just before it is stored in the cache. Use the
PSR-14 event AfterTcaCompilationEvent.