Symfony event listener service shared - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, March 17, 2022

Symfony event listener service shared

I have event listener as service, declared as:

#[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

Unfortunately, symfony create for preUpdate and postFlush another object, so I cannot used shared this.

What's wrong with it?

Thanks.



source https://stackoverflow.com/questions/71501871/symfony-event-listener-service-shared

No comments:

Post a Comment