TYPO3 事件调度器接口
我尝试在我的存储库中注入 $eventDispatcher
private EventDispatcherInterface $eventDispatcher;
public function injectEventDispatcher(EventDispatcherInterface $eventDispatcher): void
{
$this->eventDispatcher = $eventDispatcher;
}
但从 PHP 7.4 开始,您必须进行初始化。但我无法初始化 EventDispatcherInterface 并收到此错误: 初始化之前不得访问类型化属性 $eventDispatcher
如何初始化 eventDispatcher?谢谢。
I try to inject the $eventDispatcher
in my Repository
private EventDispatcherInterface $eventDispatcher;
public function injectEventDispatcher(EventDispatcherInterface $eventDispatcher): void
{
$this->eventDispatcher = $eventDispatcher;
}
But since PHP 7.4 you have to be initialized. But I cant initialize the EventDispatcherInterface and get this error :
Typed property $eventDispatcher must not be accessed before initialization
How can I initialize the eventDispatcher? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许,切换到 构造函数注入可以解决这个问题:
Maybe, switching to Constructor Injection can solve this: