Feature #63926
closed$_EXTKEY is not set in Configuration/TCA php files
0%
Description
Since TYPO3 6.1 it is possible and, in fact, recommended to define TCA in extensions in Configuration/TCA/...php files and overrides of existing tables in Configuration/TCA/Override/...php files instead of ext_tables.php. In ext_tables.php, the global variable $_EXTKEY (or $GLOBALS['_EXTKEY']) is always available as the extension key of the current extension. This simplifies some things such as forking existing extensions etc. since the name of the extension does not need to be spelled out every time.
Currently, the new TCA files do not provide this feature, i.e. $_EXTKEY is unset. For consistency and extension maintainability, I'd like to see it there, too.
Updated by Steffen Müller almost 10 years ago
You can use:
$_EXTKEY = $GLOBALS['_EXTKEY'] = 'YOUR_EXT_KEY';
seen in "EXT:news"(https://github.com/TYPO3-extensions/news/blob/master/Configuration/TCA/Overrides/tt_content.php)
Since the extension key is hardly changed, it's a good compromise.
Updated by Christian Kuhn almost 10 years ago
- Status changed from New to Rejected
Hey.
No, $_EXTKEY is not set by the core by intention. In general we strive for a reduction of global and magic variable as much as possible.
So, if we're refactoring code towards new API's, we do not introduce stuff like new additional globals anymore.
Your extension knows its name anyway, please set it accordingly in your override files.
The code in Georgs news at this point is a clear "hack" and should go away, too. I guess Georg will take care.
This issue will be set to rejected now, sorry.
Updated by Philipp Kerling almost 10 years ago
OK, but what's the rationale behind it? Is $_EXTKEY and $GLOBALS going to be deprecatd/removed in ext_tables.php, too?
If a global variable is bad, why not provide something else, e.g. a function that returns the current extension key? Sure my extension knows how it's named, but I think it shouldn't necessarily need to. In any case, having $_EXTKEY greatly reduced search/replace effort for FluidTYPO3 provider extensions I need to copy, rename and modify for different sites.
Updated by Philipp Kerling almost 10 years ago
I've thought about it again, and reached the conclusion that I can understand the decision and it wouldn't add much value after all.
Thanks for the quick reply.