Dandy
Dandy

Reputation: 1243

Access Symfony2 service layer in Doctrine entity?

I'm sure the title is pretty descriptive, but for a more in depth question: How does one access Symfony2's service layer for use in Doctrine's lifecycle callbacks? I plan on utilizing these callbacks to register an entity in my search index (which is managed by another service) every time it is created/updated/deleted.

There are a couple of things that come to mind, though, so I might as well ask them as well... Is this illegal, bad practice, or just plain terrible? Is there another solution to hooking logic involving services into the entity's lifecycle or should I decouple them altogether?

I dig any advice and am down to try new things.

Upvotes: 2

Views: 1283

Answers (1)

Mun Mun Das
Mun Mun Das

Reputation: 15002

Check out this cookbook entry.

Upvotes: 2

Related Questions