Use case: When saving a news istance in backend I want to manipulate values before saving to database.
- I include my hook in the following way in ext_localconf.php:
$GLOBALS[‘TYPO3_CONF_VARS’][‘SC_OPTIONS’][‘t3lib/class.t3lib_tcemain.php’][‘processDatamapClass’][]= VendormythemeHooksNewsControllerSettings::class;
-
In my Hooks I have write this code to Check if the Hook is Firing but it haven’t .
<?php namespace VendormythemeHooks; class NewsControllerSettings { public function processDatamap_afterDatabaseOperations($status, $table, $id, &$fieldArray,TYPO3CMSCoreDataHandlingDataHandler $pObj){ echo 'Hello world ! '; exit(); } }
I can’t upgrade the version of typo3 or even the news, but I don’t know what else to try.
I hope someone can help me. Opinions are also welcome.
Thanks in advance
2
Answers
I think you don’t have the right signature for your method, parameter
&$fieldArray
, try this :First, register the hook in the ext_localconf.php like so:
Second, rename your namespace, as it doesn’t follow naming convention:
Third, make sure your filestructure is accurate:
Fourth, fix your PHP class and give the file a descriptive name like DataHandlerHook.php:
Fifth, make sure your namespace is reflected in the extensions composer.json file:
Lastly, empty your caches.