如果通过后端保存对象,我想操作一些值并执行自定义函数。我通过我的谷歌搜索发现我必须在我的ext_localconfphp中指定这个:
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['extkey'] = 'Vendor\\Extension\\Hook\\TCEmainHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['extkey'] = 'Vendor\\Extension\\Hook\\TCEmainHook';
此外,我在我的扩展/Classes/Hook/TCEmainHook.php中创建了以下类
<?php
namespace Vendor\Extension\Hook;
class TCEmainHook {
public function processCmdmap_postProcess(
$command, $table, $id, $value,
TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {
echo '<pre>';
var_dump($command);
echo '<pre>';
die();
}
}
但无论我尝试以下哪种选项,在保存对象后都会得到一个空的后端框架:
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['NXS\\NxsReferenzen\\Hook\\TCEmainHook'] = 'EXT:nxs_referenzen/Classes/Hook/TCEmainHook.php';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][''] = 'NXS\\NxsReferenzen\\Hook\\TCEmainHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][''] = 'EXT:nxs_referenzen/Classes/Hook/TCEmainHook.php:\NXS\\NxsReferenzen\\Hook\\TCEmainHook';
我不明白我做错了什么。有人有什么建议吗?
参考解决方案: 感谢 jokumer 的建议,我查找了在 BE 模块“配置”中加载了哪些以及如何加载其他钩子。我看到我的钩子看起来与其他钩子不同,所以我检查了 powermail 钩子是如何定义的(这是我正在使用的另一个扩展),并且通过以下更改,钩子终于可以工作了:
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:nxs_referenzen/Classes/Hook/TCEmainHook.php:NXS\\NxsReferenzen\\Hook\\TCEmainHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:nxs_referenzen/Classes/Hook/TCEmainHook.php:NXS\\NxsReferenzen\\Hook\\TCEmainHook';