2

我想通过 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'
);
...

此外,我创建了以下文件:

配置/服务.yaml

services:
  My\Example\Slots\InstallUtility:
    tags:
      - name: event.listener
        identifier: 'afterExtensionInstall'
        event: TYPO3\CMS\Core\Package\Event\AfterPackageActivationEvent

之后,我向 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();
    }

    ...
}

但这不起作用。如果通过扩展管理器停用我的扩展,然后再次重新激活它,则不会发生任何事情。

我在这里错过了什么吗?

4

1 回答 1

3

我有同样的问题。解决方案如下:

  • composer dump-autoload设置好配置后运行Configuration\Services.yaml
  • 通过 Admin Tools > Maintenance > Flush TYPO3 and PHP Cache 清除缓存

您可以在 System > Configuration > Event Listeners (PSR-14) 中检查它是否有效

于 2020-08-31T11:28:18.283 回答