1
votes

Now I am using TYPO3 6.2beta5 version and in that website I need to include an XClass for the extension sr_feuser_register. Its a "PI_Base" extension and I tried the following methods to include XClass, but not working anymore;

-> localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['tx_srfeuserregister_display'] = array( 'className' => 'ux_tx_srfeuserregister_display');

-> ext_autoload.php

$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extname');

return array( 'ux_tx_srfeuserregister_display' => $extensionPath.'class.ux_tx_srfeuserregister_display.php', );

Does anybody knows the solution?

Thanks

2

2 Answers

1
votes

Your code is correct for non namespaced classes. The reasons why your code does not work can be as follows:

1) The xclass hasn't been autoloaded - Because you didn't clear "All caches" yet. The autoloader caches all paths! Additionaly autoloading breaks partially if there is an error in any of the ext_autoload.php files loaded (all extensions). You won't notice that in the frontend because no exception and no PHP error will be thrown.

2) The instance of the original class is beeing instantiated without the use of GeneralUtility::makeInstance() but directly (new tx_srfeuserregister_display)

3) The class is in fact extended but the method you want to overload is beeing used in a static way (class::method())

4) Sometimes the class key inside the Objects array is different from what you might expect (here $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['tx_srfeuserregister_display']). When I am desperate to find a reason why an XCLASS does not work, I try to devlog the classnames resolved by GeneralUtility::getImplementationForClass().

Hope some of the above helps.

0
votes

This is happened due to cache. My code was correct and I clear all the typo3temp cache and it is working now.