From 3284a369263e047bbcf43dbef78dffb07c15403f Mon Sep 17 00:00:00 2001 From: Ian Morland Date: Mon, 5 Jul 2021 14:12:08 +0100 Subject: [PATCH] Cleanup --- extend.php | 4 ++-- src/Extend/EnableRedis.php | 19 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/extend.php b/extend.php index 97c248e..5c203d3 100644 --- a/extend.php +++ b/extend.php @@ -12,7 +12,7 @@ namespace GlowingBlue\RedisSetup; use Flarum\Extend; -use GlowingBlue\RedisSetup\Extend\EnableRedis; +use GlowingBlue\RedisSetup\Extend as GBExtend; use GlowingBlue\RedisSetup\Provider\QueueProvider; return [ @@ -21,7 +21,7 @@ new Extend\Locales(__DIR__.'/resources/locale'), - new EnableRedis(), + new GBExtend\EnableRedis(), (new Extend\ServiceProvider()) ->register(QueueProvider::class), diff --git a/src/Extend/EnableRedis.php b/src/Extend/EnableRedis.php index 5daefc2..5e9e335 100644 --- a/src/Extend/EnableRedis.php +++ b/src/Extend/EnableRedis.php @@ -18,15 +18,10 @@ class EnableRedis implements ExtenderInterface public function extend(Container $container, Extension $extension = null) { $config = $this->buildConfig(); - $disabled = $this->getDisabledServices(); - - $redis = (new Redis($config)); - foreach ($disabled as $service) { - $redis->disable($service); - } - - $redis->extend($container, $extension); + (new Redis($config)) + ->disable($this->getDisabledServices()) + ->extend($container, $extension); } private function getDisabledServices(): array @@ -51,14 +46,8 @@ private function getDisabledServices(): array return $disabled; } - private function buildConfig(): array + private function buildConfig($config = []): array { - if ($this->getHost() === null) { - return []; - } - - $config = []; - $cache = [ 'host' => $this->getHost(), 'password' => $this->getPassword(),