|
1
|
|
|
<?php namespace Indatus\Dispatcher; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Dispatcher |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Ben Kuhl <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
use App; |
|
13
|
|
|
use Illuminate\Foundation\Application; |
|
14
|
|
|
|
|
15
|
|
|
class ServiceProvider extends \Illuminate\Support\ServiceProvider |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Indicates if loading of the provider is deferred. |
|
19
|
|
|
* |
|
20
|
|
|
* @var bool |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $defer = true; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Bootstrap the application events. |
|
26
|
|
|
* |
|
27
|
|
|
* @return void |
|
28
|
|
|
*/ |
|
29
|
94 |
|
public function boot() |
|
30
|
|
|
{ |
|
31
|
94 |
|
$this->package('indatus/dispatcher'); |
|
32
|
|
|
|
|
33
|
94 |
|
$resolver = $this->app->make('\Indatus\Dispatcher\ConfigResolver'); |
|
34
|
|
|
|
|
35
|
|
|
//load the scheduler of the appropriate driver |
|
36
|
|
|
$this->app->bind('Indatus\Dispatcher\Scheduling\Schedulable', function () use ($resolver) { |
|
37
|
5 |
|
return $resolver->resolveSchedulerClass(); |
|
38
|
94 |
|
}); |
|
39
|
|
|
|
|
40
|
|
|
//load the schedule service of the appropriate driver |
|
41
|
|
|
$this->app->bind('Indatus\Dispatcher\Services\ScheduleService', function () use ($resolver) { |
|
42
|
2 |
|
return $resolver->resolveServiceClass(); |
|
43
|
94 |
|
}); |
|
44
|
94 |
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Register the service provider. |
|
48
|
|
|
* |
|
49
|
|
|
* @codeCoverageIgnore |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function register() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->registerCommands(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Get the services provided by the provider. |
|
59
|
|
|
* |
|
60
|
|
|
* @return array |
|
61
|
|
|
*/ |
|
62
|
94 |
|
public function provides() |
|
63
|
|
|
{ |
|
64
|
|
|
return [ |
|
65
|
94 |
|
'command.scheduled.summary', |
|
66
|
94 |
|
'command.scheduled.make', |
|
67
|
|
|
'command.scheduled.run' |
|
68
|
94 |
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Register artisan commands |
|
73
|
|
|
* @codeCoverageIgnore |
|
74
|
|
|
*/ |
|
75
|
|
|
private function registerCommands() |
|
76
|
|
|
{ |
|
77
|
|
|
//scheduled:summary |
|
78
|
|
|
$this->app->bindShared('command.scheduled.summary', function (Application $app) { |
|
79
|
|
|
return $app->make('Indatus\Dispatcher\Commands\ScheduleSummary'); |
|
80
|
|
|
}); |
|
81
|
|
|
|
|
82
|
|
|
//scheduled:make |
|
83
|
|
|
$this->app->bindShared('command.scheduled.make', function (Application $app) { |
|
84
|
|
|
return $app->make('Indatus\Dispatcher\Commands\Make'); |
|
85
|
|
|
}); |
|
86
|
|
|
|
|
87
|
|
|
//scheduled:run |
|
88
|
|
|
$this->app->bindShared('command.scheduled.run', function (Application $app) { |
|
89
|
|
|
return $app->make('Indatus\Dispatcher\Commands\Run'); |
|
90
|
|
|
}); |
|
91
|
|
|
|
|
92
|
|
|
$this->commands($this->provides()); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|