如果对象保存在后端,我想操纵一些值并执行自定义函数。我找到了我的谷歌搜索,我必须在 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 中创建了以下课程
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';
答案 0 :(得分:2)
在本地配置(ext_localconf.php)中注册钩子类:
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][''] = 'NXS\\NxsReferenzen\\Hook\\TCEmainHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][''] = 'NXS\\NxsReferenzen\\Hook\\TCEmainHook';
确保您的钩子类具有名称空间声明:
<?php
namespace NXS\NxsReferenzen\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();
}
}