You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: messaging/multi-tenancy-support/getting-started/symfony-and-doctrine-orm.md
+23-2
Original file line number
Diff line number
Diff line change
@@ -72,9 +72,30 @@ final readonly class CustomerController extends Controller
72
72
73
73
This way we are telling Ecotone, that we want to execute this Command in context of **tenant\_a**.
74
74
75
-
## Defining Message Handlers
75
+
## Accessing Tenant's Connection
76
76
77
-
We define Message Handler the same way we would do it for Single Tenant application. Yet we need to be aware that we need to make use of correct Entity Manager for the job.
77
+
To access current Tenant's Connection, we will be using Atribute:
78
+
79
+
```php
80
+
final readonly class CustomerService
81
+
{
82
+
#[CommandHandler]
83
+
public function handle(
84
+
RegisterCustomer $command,
85
+
// Injecting Connection for current Tenant
86
+
#[MultiTenantConnection] Connection $connection
87
+
): void
88
+
{
89
+
// do something
90
+
}
91
+
}
92
+
```
93
+
94
+
By marking **Connection** with **MultiTenantConnection**, Ecotone will understand that it should inject Connection for Tenant in current context.
95
+
96
+
## Accessing Tenant's Object Manager
97
+
98
+
To access current Tenant's Object Manager, we will be using Atribute:
0 commit comments