From d2403cea3858a54173a2cdc92ea55ff40c4e3d73 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 2 Sep 2022 12:46:27 +0200 Subject: [PATCH 1/4] Add ScoutTenancyBootstrapper --- .../Integrations/ScoutTenancyBootstrapper.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php diff --git a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php new file mode 100644 index 000000000..495636a2e --- /dev/null +++ b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php @@ -0,0 +1,35 @@ +config = $config; + } + + public function bootstrap(Tenant $tenant) + { + if (! isset($this->originalScoutPrefix)) { + $this->originalScoutPrefix = $this->config->get('scout.prefix'); + } + + $this->config->set('scout.prefix', $tenant->getTenantKey()); + } + + public function revert() + { + $this->config->set('scout.prefix', $this->originalScoutPrefix); + } +} From 94adb43f7b2812f98e15a1126445603174ab0e2c Mon Sep 17 00:00:00 2001 From: PHP CS Fixer Date: Fri, 2 Sep 2022 10:46:57 +0000 Subject: [PATCH 2/4] Fix code style (php-cs-fixer) --- src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php index 495636a2e..4eeed397d 100644 --- a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php +++ b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php @@ -1,10 +1,12 @@ Date: Fri, 2 Sep 2022 17:16:57 +0200 Subject: [PATCH 3/4] extract getTenantPrefix method --- .../Integrations/ScoutTenancyBootstrapper.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php index 4eeed397d..c42242bb8 100644 --- a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php +++ b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php @@ -27,11 +27,16 @@ public function bootstrap(Tenant $tenant) $this->originalScoutPrefix = $this->config->get('scout.prefix'); } - $this->config->set('scout.prefix', $tenant->getTenantKey()); + $this->config->set('scout.prefix', $this->getTenantPrefix($tenant)); } public function revert() { $this->config->set('scout.prefix', $this->originalScoutPrefix); } + + protected function getTenantPrefix(Tenant $tenant): string + { + return (string) $tenant->getTenantKey(); + } } From a0f22c4c569429cec3a1ba9c789b78a509c31643 Mon Sep 17 00:00:00 2001 From: PHP CS Fixer Date: Fri, 2 Sep 2022 15:17:20 +0000 Subject: [PATCH 4/4] Fix code style (php-cs-fixer) --- src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php index c42242bb8..49869bb50 100644 --- a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php +++ b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php @@ -34,7 +34,7 @@ public function revert() { $this->config->set('scout.prefix', $this->originalScoutPrefix); } - + protected function getTenantPrefix(Tenant $tenant): string { return (string) $tenant->getTenantKey();