Skip to content

Commit 3e7eb44

Browse files
authored
Merge pull request #19 from yupmin/feature/fix-for-laravel57
Fix for Redis manager in Laravel 5.7
2 parents fe437ff + a280109 commit 3e7eb44

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ docker-compose.override.yml
88
phpcs.xml
99
phpspec.yml
1010
phpunit.xml
11+
/.idea

src/Configuration/Loader.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ public function getApplicationVersion()
243243
return \Illuminate\Foundation\Application::VERSION;
244244
}
245245

246+
/**
247+
* Get the current Laravel or Lumen application.
248+
*
249+
* @return \Illuminate\Contracts\Foundation\Application
250+
*/
251+
public function getApplication()
252+
{
253+
return $this->app;
254+
}
255+
246256
/**
247257
* Fetch the specified application configuration value.
248258
*

src/Manager/VersionedManagerFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ public static function make(ConfigurationLoader $config)
5959
public function makeInstance()
6060
{
6161
$class = $this->getVersionedRedisSentinelManagerClass();
62+
$app = $this->config->getApplication();
6263
$config = $this->config->get('database.redis-sentinel', [ ]);
6364
$driver = Arr::pull($config, 'client', 'predis');
6465

65-
return new RedisSentinelManager(new $class($driver, $config));
66+
if (version_compare($this->config->getApplicationVersion(), '5.6') <= 0) {
67+
return new RedisSentinelManager(new $class($driver, $config));
68+
}
69+
70+
return new RedisSentinelManager(new $class($app, $driver, $config));
71+
6672
}
6773

6874
/**

0 commit comments

Comments
 (0)