【发布时间】:2022-12-26 04:22:25
【问题描述】:
我有事件侦听器作为服务,声明为:
#[Autoconfigure(shared: true)]
#[AutoconfigureTag(name: 'doctrine.event_listener', attributes: [
'event' => Events::preUpdate,
'entity' => User::class,
'method' => 'preUpdate',
])]
#[AutoconfigureTag(name: 'doctrine.event_listener', attributes: [
'event' => Events::postFlush,
'method' => 'postFlush',
])]
class Sender
不幸的是,symfony 为 preUpdate 和 postFlush 创建了另一个对象,所以我不能使用 shared this。
它出什么问题了?
谢谢。
【问题讨论】:
标签: php symfony event-listener