|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* This file is part of Laravel Zero. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Nuno Maduro <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace LaravelZero\Framework\Components\Queue; |
|
15
|
|
|
|
|
16
|
|
|
use function class_exists; |
|
17
|
|
|
use LaravelZero\Framework\Components\AbstractComponentProvider; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @internal |
|
21
|
|
|
*/ |
|
22
|
|
|
final class Provider extends AbstractComponentProvider |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
39 |
|
public function isAvailable(): bool |
|
28
|
|
|
{ |
|
29
|
39 |
|
return class_exists(\Illuminate\Bus\BusServiceProvider::class) |
|
30
|
39 |
|
&& class_exists(\Illuminate\Queue\QueueServiceProvider::class) |
|
31
|
39 |
|
&& file_exists($this->app->configPath('queue.php')) |
|
32
|
39 |
|
&& $this->app['config']->get('queue.useDefaultProvider', true) === true; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
39 |
|
public function boot(): void |
|
39
|
|
|
{ |
|
40
|
39 |
|
if ($this->app->environment() !== 'production') { |
|
41
|
39 |
|
$this->commands( |
|
42
|
|
|
[ |
|
43
|
39 |
|
\Illuminate\Queue\Console\TableCommand::class, |
|
44
|
|
|
\Illuminate\Queue\Console\FailedTableCommand::class, |
|
45
|
|
|
\Illuminate\Foundation\Console\JobMakeCommand::class, |
|
46
|
|
|
] |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
39 |
|
$this->commands( |
|
51
|
|
|
[ |
|
52
|
39 |
|
\Illuminate\Queue\Console\WorkCommand::class, |
|
53
|
|
|
\Illuminate\Queue\Console\RetryCommand::class, |
|
54
|
|
|
\Illuminate\Queue\Console\ListenCommand::class, |
|
55
|
|
|
\Illuminate\Queue\Console\RestartCommand::class, |
|
56
|
|
|
\Illuminate\Queue\Console\ListFailedCommand::class, |
|
57
|
|
|
\Illuminate\Queue\Console\FlushFailedCommand::class, |
|
58
|
|
|
\Illuminate\Queue\Console\ForgetFailedCommand::class, |
|
59
|
|
|
] |
|
60
|
|
|
); |
|
61
|
39 |
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
*/ |
|
66
|
39 |
|
public function register(): void |
|
67
|
|
|
{ |
|
68
|
39 |
|
$this->app->register(\Illuminate\Bus\BusServiceProvider::class); |
|
69
|
39 |
|
$this->app->register(\Illuminate\Queue\QueueServiceProvider::class); |
|
70
|
|
|
|
|
71
|
39 |
|
$this->app->bind( |
|
72
|
39 |
|
\Illuminate\Queue\Worker::class, |
|
73
|
|
|
function ($app) { |
|
74
|
39 |
|
return $app['queue.worker']; |
|
75
|
39 |
|
} |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
39 |
|
$this->app->bind( |
|
79
|
39 |
|
\Illuminate\Queue\Listener::class, |
|
80
|
|
|
function ($app) { |
|
81
|
39 |
|
return $app['queue.listener']; |
|
82
|
39 |
|
} |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
39 |
|
$config = $this->app['config']; |
|
86
|
|
|
|
|
87
|
39 |
|
$config->set('queue.default', $config->get('queue.default') ?: 'default'); |
|
88
|
39 |
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|