Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getManager(?string $tenant = null): ObjectManager
Assert::notNull($connectionReference, "Lack of context about tenant in Message Headers. Please add `{$this->tenantHeaderName}` header metadata to your message.");
}

$connectionFactory = $this->getConnectionFactory();
$connectionFactory = $this->getConnectionFactory($tenant);
Assert::isTrue($connectionFactory instanceof EcotoneManagerRegistryConnectionFactory, 'Connection factory was not registered by `DbalConnection::createForManagerRegistry()`');

/** @var ManagerRegistry $managerRegistry */
Expand All @@ -94,17 +94,17 @@ public function getConnection(?string $tenant = null): Connection
return $dbalConnection->getDbalConnection();
}

public function getConnectionFactory(): ConnectionFactory
public function getConnectionFactory(?string $tenant = null): ConnectionFactory
{
$connectionReference = $this->getCurrentConnectionReferenceOrNull();
$connectionReference = $this->getCurrentConnectionReferenceOrNull($tenant);

if ($connectionReference === null) {
$tenant = $this->getCurrentTenantOrNull();
$resolvedTenant = $tenant ?? $this->getCurrentTenantOrNull();

if ($tenant === null) {
if ($resolvedTenant === null) {
throw new InvalidArgumentException("Lack of context about tenant in Message Headers. Please add `{$this->tenantHeaderName}` header metadata to your message.");
} else {
throw new InvalidArgumentException("Lack of mapping for tenant `{$tenant}`. Please provide mapping for this tenant or default connection name.");
throw new InvalidArgumentException("Lack of mapping for tenant `{$resolvedTenant}`. Please provide mapping for this tenant or default connection name.");
}
}

Expand Down
Loading