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
|
|
|
final class Provider extends AbstractComponentProvider |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
29 |
|
public function isAvailable(): bool |
25
|
|
|
{ |
26
|
29 |
|
return class_exists(\Illuminate\Bus\BusServiceProvider::class) && class_exists( |
27
|
29 |
|
\Illuminate\Queue\QueueServiceProvider::class |
28
|
29 |
|
) && file_exists($this->app->configPath('queue.php')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
29 |
|
public function boot(): void |
35
|
|
|
{ |
36
|
29 |
|
if ($this->app->environment() !== 'production') { |
37
|
28 |
|
$this->commands( |
38
|
|
|
[ |
39
|
28 |
|
\Illuminate\Queue\Console\TableCommand::class, |
40
|
|
|
\Illuminate\Queue\Console\FailedTableCommand::class, |
41
|
|
|
\Illuminate\Foundation\Console\JobMakeCommand::class, |
42
|
|
|
] |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
29 |
|
$this->commands( |
47
|
|
|
[ |
48
|
29 |
|
\Illuminate\Queue\Console\WorkCommand::class, |
49
|
|
|
\Illuminate\Queue\Console\RetryCommand::class, |
50
|
|
|
\Illuminate\Queue\Console\ListenCommand::class, |
51
|
|
|
\Illuminate\Queue\Console\RestartCommand::class, |
52
|
|
|
\Illuminate\Queue\Console\ListFailedCommand::class, |
53
|
|
|
\Illuminate\Queue\Console\FlushFailedCommand::class, |
54
|
|
|
\Illuminate\Queue\Console\ForgetFailedCommand::class, |
55
|
|
|
] |
56
|
|
|
); |
57
|
29 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
29 |
|
public function register(): void |
63
|
|
|
{ |
64
|
29 |
|
$this->app->register(\Illuminate\Bus\BusServiceProvider::class); |
65
|
29 |
|
$this->app->register(\Illuminate\Queue\QueueServiceProvider::class); |
66
|
|
|
|
67
|
29 |
|
$this->app->bind( |
68
|
29 |
|
\Illuminate\Queue\Listener::class, |
69
|
|
|
function ($app) { |
70
|
29 |
|
return $app['queue.listener']; |
71
|
29 |
|
} |
72
|
|
|
); |
73
|
|
|
|
74
|
29 |
|
$config = $this->app['config']; |
75
|
|
|
|
76
|
29 |
|
$config->set('queue.default', $config->get('queue.default') ?: 'default'); |
77
|
29 |
|
} |
78
|
|
|
} |
79
|
|
|
|