-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathDoctrineQueueProvider.php
More file actions
87 lines (74 loc) · 1.84 KB
/
DoctrineQueueProvider.php
File metadata and controls
87 lines (74 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace MaxBrokman\SafeQueue;
use Illuminate\Support\ServiceProvider;
use MaxBrokman\SafeQueue\Console\WorkCommand;
/**
* @codeCoverageIgnore
*/
class DoctrineQueueProvider extends ServiceProvider
{
protected $defer = true;
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
if (!$this->isLumen()) {
$this->publishes([
__DIR__ . '/../config/safequeue.php' => config_path('safequeue.php'),
], 'safequeue');
}
$this->mergeConfigFrom(
__DIR__ . '/../config/safequeue.php', 'safequeue'
);
$this->registerWorker();
}
public function boot()
{
$this->commands('command.safeQueue.work');
}
/**
* @return void
*/
protected function registerWorker()
{
$this->registerWorkCommand();
$this->app->singleton('safeQueue.worker', function ($app) {
return new Worker($app['queue'], $app['events'],
$app['Doctrine\Common\Persistence\ManagerRegistry'], $app['Illuminate\Contracts\Debug\ExceptionHandler']);
});
}
/**
* @return void
*/
protected function registerWorkCommand()
{
$this->app->singleton('command.safeQueue.work', function ($app) {
return new WorkCommand(
$app['safeQueue.worker'],
$app['config']->get('safequeue')
);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
'safeQueue.worker',
'command.safeQueue.work'
];
}
/**
* @return bool
*/
protected function isLumen()
{
return str_contains($this->app->version(), 'Lumen');
}
}