Skip to content

Commit 2fdc72f

Browse files
committed
fix #103
1 parent a993295 commit 2fdc72f

2 files changed

Lines changed: 14 additions & 27 deletions

File tree

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "topthink/think-queue",
3-
"description": "The ThinkPHP5 Queue Package",
3+
"description": "The ThinkPHP6 Queue Package",
44
"authors": [
55
{
66
"name": "yunwuxin",
@@ -25,8 +25,7 @@
2525
"require": {
2626
"ext-json": "*",
2727
"topthink/think-helper": "^3.0.4",
28-
"topthink/framework": "^6.0.0",
29-
"topthink/think-factory": "^1.0.0",
28+
"topthink/framework": "^6.0",
3029
"symfony/process": "^4.2",
3130
"nesbot/carbon": "^2.16"
3231
},

src/Queue.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,38 @@
1111

1212
namespace think;
1313

14-
use InvalidArgumentException;
15-
use think\cache\driver\Redis;
16-
use think\helper\Str;
1714
use think\queue\Connector;
1815
use think\queue\connector\Database;
16+
use think\queue\connector\Redis;
1917

2018
/**
2119
* Class Queue
2220
* @package think\queue
2321
*
24-
* @method Connector driver($driver = null)
2522
* @mixin Database
2623
* @mixin Redis
2724
*/
28-
class Queue extends Factory
25+
class Queue extends Manager
2926
{
3027
protected $namespace = '\\think\\queue\\connector\\';
3128

32-
/**
33-
* Get the queue connector configuration.
34-
*
35-
* @param string $name
36-
* @return array
37-
*/
38-
protected function getConfig($name)
29+
protected function resolveType(string $name)
3930
{
40-
return $this->app->config->get("queue.connections.{$name}", ['type' => 'sync']);
31+
return $this->app->config->get("queue.connections.{$name}.type", 'sync');
4132
}
4233

43-
protected function createDriver($name)
34+
protected function resolveConfig(string $name)
4435
{
45-
$driver = $this->getConfig($name)['type'];
46-
47-
$class = false !== strpos($driver, '\\') ? $driver : $this->namespace . Str::studly($driver);
36+
return $this->app->config->get("queue.connections.{$name}");
37+
}
4838

39+
protected function createDriver(string $name)
40+
{
4941
/** @var Connector $driver */
50-
if (class_exists($class)) {
51-
$driver = $this->app->invokeClass($class, [$this->getConfig($driver)]);
52-
53-
return $driver->setApp($this->app)
54-
->setConnection($name);
55-
}
42+
$driver = parent::createDriver($name);
5643

57-
throw new InvalidArgumentException("Driver [$driver] not supported.");
44+
return $driver->setApp($this->app)
45+
->setConnection($name);
5846
}
5947

6048
/**

0 commit comments

Comments
 (0)