Fox*_*Fox 3 typo3 event-listener event-handling typo3-10.x
我想通过 PSR-14 事件监听器注册替换旧的信号注册。所以我从 ext_localconf.php 中删除了以下内容:
ext_localconf.php
...
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class,
'afterExtensionInstall',
\My\Example\Slots\InstallUtility::class,
'afterExtensionInstall'
);
...
Run Code Online (Sandbox Code Playgroud)
此外,我还创建了以下文件:
配置/服务.yaml
services:
My\Example\Slots\InstallUtility:
tags:
- name: event.listener
identifier: 'afterExtensionInstall'
event: TYPO3\CMS\Core\Package\Event\AfterPackageActivationEvent
Run Code Online (Sandbox Code Playgroud)
之后,我向 My\Example\Slots\InstallUtility 添加了一个调用函数:
namespace My\Example\Slots;
use TYPO3\CMS\Core\Package\Event\AfterPackageActivationEvent;
class InstallUtility
{
/**
* @param AfterPackageActivationEvent $event
*/
public function __invoke(AfterPackageActivationEvent $event): void
{
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump('event got triggered'); die();
}
...
}
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。如果通过扩展管理器停用我的扩展然后再次重新激活它,则不会发生任何情况。
我在这里错过了什么吗?
我有同样的问题。解决方案如下:
composer dump-autoload设置配置后运行Configuration\Services.yaml您可以在“系统”>“配置”>“事件监听器”(PSR-14) 中检查它是否有效
| 归档时间: |
|
| 查看次数: |
1361 次 |
| 最近记录: |