Skip to content

Commit 21c7f7e

Browse files
dgafkagitbook-bot
authored andcommitted
GITBOOK-839: No subject
1 parent 27d1cd4 commit 21c7f7e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

messaging/multi-tenancy-support/getting-started/symfony-and-doctrine-orm.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,30 @@ final readonly class CustomerController extends Controller
7272

7373
This way we are telling Ecotone, that we want to execute this Command in context of **tenant\_a**.
7474

75-
## Defining Message Handlers
75+
## Accessing Tenant's Connection
7676

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:
7899

79100
```php
80101
final readonly class CustomerService

0 commit comments

Comments
 (0)