Ideal setup for a SaaS Multi Tenant System #37
Replies: 1 comment 1 reply
-
Hi Marvin, Thank you for your question and for your kind words about the Multi-Tenancy Bundle. To answer your question, yes, it is possible to centralize the tenant switch event (SwitchDbEvent) instead of dispatching it everywhere you need to create, edit, or delete tenant-specific entities. A common approach is to automatically switch the entity manager to the correct tenant database after a successful login or another key event, like when a user session starts In this scenario, you can listen to Symfony events such as |
Beta Was this translation helpful? Give feedback.
-
Hello Ramy,
first of all, thank you very much for this great bundle! I think you have solved a fundamental problem for everyone who wants to use Symfony Mandant-enabled.
I am wondering if it is possible to centralize the tenant switch event
$switchEvent = new SwitchDbEvent($tenantUser->getTenantDbConfig()->getId()); $this->dispatcher->dispatch($switchEvent);
Instead of using it everywhere I want to create, edit or delete some tenant specific entites, would it be easier to generally switch the main entity manager after e.g. you successfully logged in with your Main/TenantUser and got authorized?
Many thanks for your help!
Marvin
Beta Was this translation helpful? Give feedback.
All reactions