When creating new database records, TYPO3 assigns them a temporary UID, which looks like this: NEW56fe740dd5a455.64167468
. The record gets its real UID when it is inserted into the database.
In the above hook, the record is already inserted into the database, so it has a numerical uid assigned. How do I get that uid from a given temporary UID?
Ok, found it. The fourth parameter of the hook-method is the datahandler object, which has a property substNEWwithIDs
, an associative array mapping temporary UIDs to the real UIDs.
One can use it like this:
public function processDatamap_afterDatabaseOperations($action, $table, $uid, $datahandler)
{
if (GeneralUtility::isFirstPartOfStr($uid, 'NEW')) {
$uid = $datahandler->substNEWwithIDs[$uid];
}
// Do something with the UID
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With