mirror of
https://github.com/archtechx/tenancy.git
synced 2026-06-21 18:24:04 +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:
parent
0c11f29c19
commit
9f94505cb4
16 changed files with 82 additions and 82 deletions
38
src/Bootstrappers/Integrations/ScoutPrefixBootstrapper.php
Normal file
38
src/Bootstrappers/Integrations/ScoutPrefixBootstrapper.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Bootstrappers\Integrations;
|
||||
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
|
||||
class ScoutPrefixBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
protected ?string $originalScoutPrefix = null;
|
||||
|
||||
public function __construct(
|
||||
protected Repository $config,
|
||||
) {
|
||||
}
|
||||
|
||||
public function bootstrap(Tenant $tenant): void
|
||||
{
|
||||
if ($this->originalScoutPrefix === null) {
|
||||
$this->originalScoutPrefix = $this->config->get('scout.prefix');
|
||||
}
|
||||
|
||||
$this->config->set('scout.prefix', $this->getTenantPrefix($tenant));
|
||||
}
|
||||
|
||||
public function revert(): void
|
||||
{
|
||||
$this->config->set('scout.prefix', $this->originalScoutPrefix);
|
||||
}
|
||||
|
||||
protected function getTenantPrefix(Tenant $tenant): string
|
||||
{
|
||||
return (string) $tenant->getTenantKey();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue