ExtensionManagementUtility::extPath returns different file paths
since TYPO3 7.5, \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(); returns different file paths.
- Create a dummy extension including a valid TCA
- Edit TCA and add following in ext_tables.php:
$GLOBALS['TCA']['tx_dummy_domain_model_dummy'] = array(
'ctrl' => array(
'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Dummy.php',
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_dummy_domain_model_dummy.gif'
Go to the Backend, open "Configuration" check "$GLOBALS[TCA]" Array.
- iconfile will be: "../typo3conf/ext/dummy/Resources/Public/Icons/tx_dummy_domain_model_dummy.gif"
- dynamicConfigFile will be: "/var/www/public/typo3conf/ext/dummy/Configuration/TCA/Dummy.php"
Because of "iconfile" has to be prefixed with "EXT:" the iconfile will never been shown in the Backend List-View.
If you return the complete TCA array in "typo3conf/ext/dummy/Configuration/TCA/tx_dummy_domain_model_dummy.php" instead of set the ctrl array in ext_tables.php "extRelPath()" will return the correct prefixed file paths for both keys (dynamicConfigFile and iconfile)
#1 Updated by Zsolt Molnar over 4 years ago
you have used the \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath method for the 'dynamicConfigFile' but for the other one \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath, so extPath VS. extRelPath. It makes sense why you got two different return value.
#2 Updated by Christopher Orth over 4 years ago
I dont think it makes sense the same method returns sometimes absolute, sometimes relative paths but nevermind.
This isnt the main problem here. The problem is using extPath() in your ext_tables.php file will return a unprefixed wrong relative path since 7.5 (please see my example).
The icon cant be found with that path so your icon file cant be rendered in the TYPO3 Backend.
Unfortunately you need the "EXT:" prefixed file path for icons, or the correct unprefixed path. Neither is the case here. Using the same Method in "typo3conf/ext/dummy/Configuration/TCA/tx_dummy_domain_model_dummy.php" will return the correct prefixed path.
You're absolutely right, i used different methods for "dynamicConfigFile" and "iconfile" in my example, bad one ;)
But it doesnt matter which method you use, the icon cant be found anymore.
#3 Updated by Morton Jonuschat about 4 years ago
- Status changed from New to Rejected
As discussed in the comments the original report is the result of using different methods of ExtensionManagementUtility to get the paths.
While using relative paths for the iconfile is deprecated and results in an entry in the deprecation log it still works when used like this:
As the TCA is being migrated and cached it is required to flush the system caches after a change in the TCA config to activate the changes.
#4 Updated by taywa gmbh about 4 years ago
in typo3 7.6 the suggested "solution" ExtensionManagementUtility::extRelPath('extensionname').'Resources/Public/Icons/dummy.gif' to migrate old extensions does not work anymore. i tried different approaches and what worked for me in the end was:
'iconfile' => 'EXT:'.$_EXTKEY.'/icons/performance.gif',