1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 23:34:03 +00:00

Rename bootstrappers (#40)

* SessionTenancyBootstrapper -> DatabaseSessionBootstrapper

* FortifyRouteTenancyBootstrapper -> FortifyRouteBootstrapper

* BatchTenancyBootstrapper -> JobBatchBootstrapper

* ScoutTenancyBootstrapper -> ScoutPrefixBootstrapper, also fix logic and remove todo

* MailTenancyBootstrapper -> MailConfigBootstrapper

* PrefixCacheTenancyBootstrapper -> CacheTenancyBootstrapper

* remove todo

* improve config file
This commit is contained in:
Samuel Štancl 2024-03-28 03:18:23 +01:00 committed by GitHub
parent 0c11f29c19
commit 9f94505cb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 82 additions and 82 deletions

View file

@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Bootstrappers;
use Illuminate\Bus\DatabaseBatchRepository;
use Illuminate\Database\Connection;
use Illuminate\Database\DatabaseManager;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
// todo add docblock
class BatchTenancyBootstrapper implements TenancyBootstrapper
{
/**
* The previous database connection instance.
*/
protected ?Connection $previousConnection = null;
public function __construct(
protected DatabaseBatchRepository $batchRepository,
protected DatabaseManager $databaseManager
) {
}
public function bootstrap(Tenant $tenant): void
{
// Update batch repository connection to use the tenant connection
$this->previousConnection = $this->batchRepository->getConnection();
$this->batchRepository->setConnection($this->databaseManager->connection('tenant'));
}
public function revert(): void
{
if ($this->previousConnection) {
// Replace batch repository connection with the previously replaced one
$this->batchRepository->setConnection($this->previousConnection);
$this->previousConnection = null;
}
}
}