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.", 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; + } }