1
|
|
|
<?php namespace Maqe\Qwatcher; |
2
|
|
|
|
3
|
|
|
use Queue; |
4
|
|
|
use Illuminate\Support\ServiceProvider; |
5
|
|
|
use Illuminate\Support\Facades\Log; |
6
|
|
|
use Maqe\Qwatcher\Facades\Qwatch; |
7
|
|
|
use Maqe\Qwatcher\Tracks\FailedTracks; |
8
|
|
|
use Maqe\Qwatcher\Tracks\ProcessTracks; |
9
|
|
|
use Maqe\Qwatcher\Tracks\SucceedTracks; |
10
|
|
|
|
11
|
|
|
class QwatcherServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Bootstrap any application services. |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public function boot() |
19
|
|
|
{ |
20
|
|
|
Queue::before(function ($job) { |
21
|
|
|
Qwatch::tracks(new ProcessTracks($job->job->getJobId(), $job->job)); |
22
|
|
|
}); |
23
|
|
|
|
24
|
|
|
Queue::after(function ($job) { |
25
|
|
|
Qwatch::tracks(new SucceedTracks($job->job->getJobId(), $job->job)); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
Queue::failing(function ($job) { |
29
|
|
|
Qwatch::tracks(new FailedTracks($job->job->getJobId(), $job->job)); |
30
|
|
|
}); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Register the service provider. |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
|
|
public function register() |
39
|
|
|
{ |
40
|
|
|
/** |
41
|
|
|
* publish migrations |
42
|
|
|
*/ |
43
|
|
|
$this->publishes([__DIR__ . '/../database/migrations' => database_path('migrations')], 'migrations'); |
44
|
|
|
$this->publishes([__DIR__ . '/../config/qwatcher.php' => config_path('qwatcher.php')], 'config'); |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* merge config |
48
|
|
|
*/ |
49
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../config/qwatcher.php', 'qwatcher'); |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Register Facade |
53
|
|
|
*/ |
54
|
|
|
$this->app->bind('Qwatch', function () { |
55
|
|
|
return (new Qwatcher); |
56
|
|
|
}); |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Register artisan Commands |
60
|
|
|
*/ |
61
|
|
|
// $this->commands([ |
|
|
|
|
62
|
|
|
// \Maqe\Qwatcher\Commands\SomeCommand1::class, |
63
|
|
|
// \Maqe\Qwatcher\Commands\SomeCommand2::class |
64
|
|
|
// ]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get the services provided by the provider. |
69
|
|
|
* |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function provides() |
73
|
|
|
{ |
74
|
|
|
return ['Qwatch']; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.