From 44c1c9c0b586a9bada9570c66f99f802cd88dfca Mon Sep 17 00:00:00 2001 From: Abderrazzak OXA Date: Wed, 9 Sep 2020 01:31:04 +0200 Subject: [PATCH 1/2] Support Laravel 8 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index abb3683..92c2969 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ ], "require": { "php": ">=5.4.0", - "illuminate/support": ">=4.2 <8.0", - "illuminate/cache": ">=4.2 <8.0" + "illuminate/support": ">=4.2 <9.0", + "illuminate/cache": ">=4.2 <9.0" }, "suggest": { "illuminate/filesystem": "Save settings to a JSON file.", From 94da780a68378849ac8d3b189c2f58362a174b2e Mon Sep 17 00:00:00 2001 From: Abderrazzak OXA Date: Wed, 9 Sep 2020 14:29:43 +0200 Subject: [PATCH 2/2] Support Laravel >= 8 --- src/SettingsManager.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/SettingsManager.php b/src/SettingsManager.php index 004280a..adb9a14 100644 --- a/src/SettingsManager.php +++ b/src/SettingsManager.php @@ -23,7 +23,7 @@ public function createJsonDriver() { $path = $this->getConfig('anlutro/l4-settings::path'); - $store = new JsonSettingStore($this->app['files'], $path); + $store = new JsonSettingStore($this->getSupportedContainer()['files'], $path); return $this->wrapDriver($store); } @@ -31,7 +31,7 @@ public function createJsonDriver() public function createDatabaseDriver() { $connectionName = $this->getConfig('anlutro/l4-settings::connection'); - $connection = $this->app['db']->connection($connectionName); + $connection = $this->getSupportedContainer()['db']->connection($connectionName); $table = $this->getConfig('anlutro/l4-settings::table'); $keyColumn = $this->getConfig('anlutro/l4-settings::keyColumn'); $valueColumn = $this->getConfig('anlutro/l4-settings::valueColumn'); @@ -57,7 +57,7 @@ protected function getConfig($key) $key = str_replace('anlutro/l4-settings::', 'settings.', $key); } - return $this->app['config']->get($key); + return $this->getSupportedContainer()['config']->get($key); } protected function wrapDriver($store) @@ -66,7 +66,7 @@ protected function wrapDriver($store) if ($this->getConfig('anlutro/l4-settings::enableCache')) { $store->setCache( - $this->app['cache'], + $this->getSupportedContainer()['cache'], $this->getConfig('anlutro/l4-settings::cacheTtl'), $this->getConfig('anlutro/l4-settings::forgetCacheByWrite') ); @@ -74,4 +74,9 @@ protected function wrapDriver($store) return $store; } + + protected function getSupportedContainer() + { + return isset($this->app) ? $this->app : $this->container; + } }